| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <chrono> | ||
| 2 | #include <cstring> | ||
| 3 | #include <exception> | ||
| 4 | #include <string> | ||
| 5 | #include <stdexcept> | ||
| 6 | #include <map> | ||
| 7 | |||
| 8 | #include "base/general.h" | ||
| 9 | #include "base/version.h" | ||
| 10 | #include "base/zapp.h" | ||
| 11 | #include "dialog/info.h" | ||
| 12 | #include "metadata/metadata.h" | ||
| 13 | |||
| 14 | #include "base/qrs.h" | ||
| 15 | #include "base/dmap.h" | ||
| 16 | #include "base/packfile.h" | ||
| 17 | #include "base/cpool.h" | ||
| 18 | #include "base/autocombo.h" | ||
| 19 | #include "base/gui.h" | ||
| 20 | #include "base/msgstr.h" | ||
| 21 | #include "zc/zelda.h" | ||
| 22 | #include "zq/zq_class.h" | ||
| 23 | #include "zq/zq_misc.h" | ||
| 24 | #include "zq/zquest.h" | ||
| 25 | #include "base/qst.h" | ||
| 26 | #include "base/colors.h" | ||
| 27 | #include "tiles.h" | ||
| 28 | #include "base/zsys.h" | ||
| 29 | #include "sprite.h" | ||
| 30 | #include "items.h" | ||
| 31 | #include "zc/zc_sys.h" | ||
| 32 | #include "base/md5.h" | ||
| 33 | #include "hero_tiles.h" | ||
| 34 | #include "subscr.h" | ||
| 35 | #include "zq/zq_strings.h" | ||
| 36 | #include "zq/zq_subscr.h" | ||
| 37 | #include "zc/ffscript.h" | ||
| 38 | #include "base/util.h" | ||
| 39 | #include "zq/zq_files.h" | ||
| 40 | #include "dialog/alert.h" | ||
| 41 | #include "slopes.h" | ||
| 42 | #include "drawing.h" | ||
| 43 | #include "zinfo.h" | ||
| 44 | #include "zq/render_minimap.h" | ||
| 45 | #include "base/mapscr.h" | ||
| 46 | #include "iter.h" | ||
| 47 | #include <fmt/format.h> | ||
| 48 | #include <filesystem> | ||
| 49 | |||
| 50 | #ifdef __EMSCRIPTEN__ | ||
| 51 | #include "base/emscripten_utils.h" | ||
| 52 | #endif | ||
| 53 | |||
| 54 | namespace fs = std::filesystem; | ||
| 55 | |||
| 56 | using namespace util; | ||
| 57 | |||
| 58 | extern uint8_t ViewLayer3BG, ViewLayer2BG; | ||
| 59 | extern int32_t LayerDitherBG, LayerDitherSz; | ||
| 60 | extern bool NoHighlightLayer0; | ||
| 61 | |||
| 62 | using std::string; | ||
| 63 | using std::pair; | ||
| 64 | |||
| 65 | #define COLOR_SOLID vc(4) | ||
| 66 | #define COLOR_SLOPE vc(13) | ||
| 67 | #define COLOR_LADDER vc(6) | ||
| 68 | //#define COLOR_EFFECT vc(10) | ||
| 69 | |||
| 70 | //const char zqsheader[30]="ZQuest Classic String Table\n\x01"; | ||
| 71 | extern char msgbuf[MSG_NEW_SIZE*8]; | ||
| 72 | |||
| 73 | extern string zScript; | ||
| 74 | |||
| 75 | 12 | zmap Map; | |
| 76 | int32_t prv_mode=0; | ||
| 77 | |||
| 78 | bool save_warn=true; | ||
| 79 | |||
| 80 | ✗ | int32_t COMBOPOS(int32_t x, int32_t y) | |
| 81 | { | ||
| 82 | ✗ | return (((y) & 0xF0) + ((x) >> 4)); | |
| 83 | } | ||
| 84 | ✗ | int32_t COMBOPOS_B(int32_t x, int32_t y) | |
| 85 | { | ||
| 86 | ✗ | if(unsigned(x) >= 256 || unsigned(y) >= 176) | |
| 87 | ✗ | return -1; | |
| 88 | ✗ | return COMBOPOS(x,y); | |
| 89 | ✗ | } | |
| 90 | ✗ | int32_t COMBOX(int32_t pos) | |
| 91 | { | ||
| 92 | ✗ | return ((pos) % 16 * 16); | |
| 93 | } | ||
| 94 | ✗ | int32_t COMBOY(int32_t pos) | |
| 95 | { | ||
| 96 | ✗ | return ((pos) & 0xF0); | |
| 97 | } | ||
| 98 | |||
| 99 | ✗ | void reset_dmap(int32_t index) | |
| 100 | { | ||
| 101 | ✗ | bound(index,0,MAXDMAPS-1); | |
| 102 | ✗ | DMaps[index].clear(); | |
| 103 | ✗ | DMaps[index].title = ""; | |
| 104 | ✗ | sprintf(DMaps[index].intro, " "); | |
| 105 | ✗ | } | |
| 106 | |||
| 107 | ✗ | void reset_dmaps() | |
| 108 | { | ||
| 109 | ✗ | for(int32_t i=0; i<MAXDMAPS; i++) | |
| 110 | ✗ | reset_dmap(i); | |
| 111 | ✗ | } | |
| 112 | |||
| 113 | ✗ | void truncate_dmap_title(std::string& title) | |
| 114 | { | ||
| 115 | ✗ | title.resize(21, ' '); | |
| 116 | ✗ | } | |
| 117 | |||
| 118 | ✗ | mapscr* zmap::get_prvscr() | |
| 119 | { | ||
| 120 | ✗ | return &prvscr; | |
| 121 | } | ||
| 122 | |||
| 123 |
2/4✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
|
23 | zmap::zmap() |
| 124 | { | ||
| 125 | 23 | can_paste=false; | |
| 126 | 23 | prv_cmbcycle=0; | |
| 127 | 23 | prv_advance=0; | |
| 128 | 23 | prv_freeze=0; | |
| 129 | 23 | copyffc=-1; | |
| 130 | |||
| 131 | 23 | memset(scrpos, 0, sizeof(scrpos)); | |
| 132 | 23 | memset(scrview, 0, sizeof(scrview)); | |
| 133 | 23 | screens=NULL; | |
| 134 | 23 | prv_time=0; | |
| 135 | 23 | prv_scr=0; | |
| 136 | 23 | prv_map=0; | |
| 137 | 23 | copyscr=0; | |
| 138 | 23 | cursor={}; | |
| 139 | copymap=0; | ||
| 140 | layer_target_map = 0; | ||
| 141 | layer_target_scr = 0; | ||
| 142 | layer_target_multiple = 0; | ||
| 143 | ✗ | } | |
| 144 | |||
| 145 | 11 | void zmap::clear() | |
| 146 | { | ||
| 147 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | *this = zmap(); |
| 148 | 11 | } | |
| 149 | ✗ | void zmap::force_refr_pointer() | |
| 150 | { | ||
| 151 | ✗ | if(unsigned(cursor.map) > map_count || (cursor.map*MAPSCRS > TheMaps.size())) | |
| 152 | ✗ | screens = nullptr; | |
| 153 | ✗ | else screens = &TheMaps[cursor.map*MAPSCRS]; | |
| 154 | ✗ | } | |
| 155 | ✗ | bool zmap::CanUndo() | |
| 156 | { | ||
| 157 | ✗ | return undo_stack.size() > 0; | |
| 158 | } | ||
| 159 | ✗ | bool zmap::CanRedo() | |
| 160 | { | ||
| 161 | ✗ | return redo_stack.size() > 0; | |
| 162 | } | ||
| 163 | ✗ | bool zmap::CanPaste() | |
| 164 | { | ||
| 165 | ✗ | return can_paste; | |
| 166 | } | ||
| 167 | ✗ | int32_t zmap::CopyScr() | |
| 168 | { | ||
| 169 | ✗ | return (copymap<<8)+copyscr; | |
| 170 | } | ||
| 171 | ✗ | int32_t zmap::getCopyFFC() | |
| 172 | { | ||
| 173 | ✗ | return copyffc; | |
| 174 | } | ||
| 175 | ✗ | set_ffc_command::data_t zmap::getCopyFFCData() | |
| 176 | { | ||
| 177 | ✗ | return set_ffc_command::create_data(copymapscr.ffcs[copyffc]); | |
| 178 | } | ||
| 179 | 63 | int32_t zmap::getMapCount() | |
| 180 | { | ||
| 181 | 63 | return map_count; | |
| 182 | } | ||
| 183 | ✗ | int32_t zmap::getLayerTargetMap() | |
| 184 | { | ||
| 185 | ✗ | return layer_target_map; | |
| 186 | } | ||
| 187 | ✗ | int32_t zmap::getLayerTargetScr() | |
| 188 | { | ||
| 189 | ✗ | return layer_target_scr; | |
| 190 | } | ||
| 191 | ✗ | int32_t zmap::getLayerTargetMultiple() | |
| 192 | { | ||
| 193 | ✗ | return layer_target_multiple; | |
| 194 | } | ||
| 195 | ✗ | bool zmap::isDungeon(int32_t scr) | |
| 196 | { | ||
| 197 | ✗ | for(int32_t i=0; i<4; i++) | |
| 198 | { | ||
| 199 | ✗ | if(screens[scr].data[i]!=screens[TEMPLATE].data[i]) | |
| 200 | { | ||
| 201 | ✗ | return false; | |
| 202 | } | ||
| 203 | ✗ | } | |
| 204 | |||
| 205 | ✗ | return true; | |
| 206 | ✗ | } | |
| 207 | |||
| 208 | ✗ | bool zmap::clearall(bool validate) | |
| 209 | { | ||
| 210 | ✗ | Color=0; | |
| 211 | char tbuf[10]; | ||
| 212 | |||
| 213 | ✗ | if((header.templatepath[0]!=0)&&validate) | |
| 214 | { | ||
| 215 | ✗ | if(!valid_zqt(header.templatepath)) | |
| 216 | { | ||
| 217 | ✗ | jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 218 | ✗ | return false; | |
| 219 | } | ||
| 220 | ✗ | } | |
| 221 | |||
| 222 | ✗ | for(int32_t i=0; i<map_count; i++) | |
| 223 | { | ||
| 224 | ✗ | setCurrMap(i); | |
| 225 | ✗ | sprintf(tbuf, "%d", i); | |
| 226 | ✗ | clearmap(true); | |
| 227 | ✗ | } | |
| 228 | |||
| 229 | ✗ | setCurrMap(0); | |
| 230 | ✗ | return true; | |
| 231 | ✗ | } | |
| 232 | |||
| 233 | ✗ | bool zmap::reset_templates(bool validate) | |
| 234 | { | ||
| 235 | //why are we doing this? | ||
| 236 | ✗ | if(colordata==NULL) | |
| 237 | { | ||
| 238 | ✗ | return false; | |
| 239 | } | ||
| 240 | |||
| 241 | //int32_t ret; | ||
| 242 | ✗ | word version, build, dummy, sversion=0; | |
| 243 | byte dummyc; | ||
| 244 | word dummyw; | ||
| 245 | //int32_t section_size; | ||
| 246 | word temp_map_count; | ||
| 247 | ✗ | mapscr temp_mapscr; | |
| 248 | ✗ | PACKFILE *f=NULL; | |
| 249 | |||
| 250 | // setPackfilePassword(datapwd); | ||
| 251 | ✗ | f=open_quest_template(&header, "modules/classic/default.qst", validate); | |
| 252 | ✗ | get_version_and_build(f, &version, &build); | |
| 253 | |||
| 254 | ✗ | if(!find_section(f, ID_MAPS)) | |
| 255 | { | ||
| 256 | // setPackfilePassword(NULL); | ||
| 257 | ✗ | return false; | |
| 258 | } | ||
| 259 | |||
| 260 | //section version info | ||
| 261 | ✗ | if(!p_igetw(&sversion,f)) | |
| 262 | { | ||
| 263 | ✗ | return false; | |
| 264 | } | ||
| 265 | |||
| 266 | ✗ | if(!p_igetw(&dummy,f)) | |
| 267 | { | ||
| 268 | ✗ | return false; | |
| 269 | } | ||
| 270 | |||
| 271 | //section size | ||
| 272 | dword dummy_size; | ||
| 273 | ✗ | if(!p_igetl(&dummy_size,f)) | |
| 274 | { | ||
| 275 | ✗ | return false; | |
| 276 | } | ||
| 277 | |||
| 278 | //finally... section data | ||
| 279 | ✗ | if(!p_igetw(&temp_map_count,f)) | |
| 280 | { | ||
| 281 | ✗ | return false; | |
| 282 | } | ||
| 283 | |||
| 284 | ✗ | if(version>12) | |
| 285 | { | ||
| 286 | ✗ | if(!p_getc(&dummyc,f)) | |
| 287 | ✗ | return qe_invalid; | |
| 288 | |||
| 289 | ✗ | if(!p_getc(&dummyc,f)) | |
| 290 | ✗ | return qe_invalid; | |
| 291 | |||
| 292 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 293 | ✗ | return qe_invalid; | |
| 294 | |||
| 295 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 296 | ✗ | return qe_invalid; | |
| 297 | |||
| 298 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 299 | ✗ | return qe_invalid; | |
| 300 | |||
| 301 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 302 | ✗ | return qe_invalid; | |
| 303 | |||
| 304 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 305 | ✗ | return qe_invalid; | |
| 306 | |||
| 307 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 308 | ✗ | return qe_invalid; | |
| 309 | |||
| 310 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 311 | ✗ | return qe_invalid; | |
| 312 | |||
| 313 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 314 | ✗ | return qe_invalid; | |
| 315 | |||
| 316 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 317 | ✗ | return qe_invalid; | |
| 318 | |||
| 319 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 320 | ✗ | return qe_invalid; | |
| 321 | |||
| 322 | ✗ | if(!p_getc(&dummyc,f)) | |
| 323 | ✗ | return qe_invalid; | |
| 324 | |||
| 325 | ✗ | if(!p_getc(&dummyc,f)) | |
| 326 | ✗ | return qe_invalid; | |
| 327 | ✗ | } | |
| 328 | |||
| 329 | ✗ | for(int32_t i=0; i<MAPSCRSNORMAL; ++i) | |
| 330 | { | ||
| 331 | ✗ | readmapscreen(f, &header, &temp_mapscr, sversion); | |
| 332 | ✗ | } | |
| 333 | |||
| 334 | ✗ | readmapscreen(f, &header, &TheMaps[128], sversion); | |
| 335 | ✗ | readmapscreen(f, &header, &TheMaps[129], sversion); | |
| 336 | |||
| 337 | ✗ | for(int32_t i=0; i<(MAPSCRS-(MAPSCRSNORMAL+2)); ++i) | |
| 338 | { | ||
| 339 | ✗ | readmapscreen(f, &header, &temp_mapscr, sversion); | |
| 340 | ✗ | } | |
| 341 | |||
| 342 | ✗ | if(version>12) | |
| 343 | { | ||
| 344 | ✗ | if(!p_getc(&dummyc,f)) | |
| 345 | ✗ | return qe_invalid; | |
| 346 | |||
| 347 | ✗ | if(!p_getc(&dummyc,f)) | |
| 348 | ✗ | return qe_invalid; | |
| 349 | |||
| 350 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 351 | ✗ | return qe_invalid; | |
| 352 | |||
| 353 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 354 | ✗ | return qe_invalid; | |
| 355 | |||
| 356 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 357 | ✗ | return qe_invalid; | |
| 358 | |||
| 359 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 360 | ✗ | return qe_invalid; | |
| 361 | |||
| 362 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 363 | ✗ | return qe_invalid; | |
| 364 | |||
| 365 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 366 | ✗ | return qe_invalid; | |
| 367 | |||
| 368 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 369 | ✗ | return qe_invalid; | |
| 370 | |||
| 371 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 372 | ✗ | return qe_invalid; | |
| 373 | |||
| 374 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 375 | ✗ | return qe_invalid; | |
| 376 | |||
| 377 | ✗ | if(!p_igetw(&dummyw,f)) | |
| 378 | ✗ | return qe_invalid; | |
| 379 | |||
| 380 | ✗ | if(!p_getc(&dummyc,f)) | |
| 381 | ✗ | return qe_invalid; | |
| 382 | |||
| 383 | ✗ | if(!p_getc(&dummyc,f)) | |
| 384 | ✗ | return qe_invalid; | |
| 385 | ✗ | } | |
| 386 | |||
| 387 | ✗ | for(int32_t i=0; i<MAPSCRSNORMAL; ++i) | |
| 388 | { | ||
| 389 | ✗ | readmapscreen(f, &header, &temp_mapscr, sversion); | |
| 390 | ✗ | } | |
| 391 | |||
| 392 | ✗ | readmapscreen(f, &header, &TheMaps[MAPSCRS+128], sversion); | |
| 393 | ✗ | readmapscreen(f, &header, &TheMaps[MAPSCRS+129], sversion); | |
| 394 | |||
| 395 | ✗ | pack_fclose(f); | |
| 396 | ✗ | clear_quest_tmpfile(); | |
| 397 | |||
| 398 | ✗ | return true; | |
| 399 | ✗ | } | |
| 400 | |||
| 401 | ✗ | bool zmap::clearmap(bool newquest) | |
| 402 | { | ||
| 403 | ✗ | if(cursor.map<map_count) | |
| 404 | { | ||
| 405 | ✗ | for(int32_t i=0; i<MAPSCRS-(newquest?0:TEMPLATES); i++) | |
| 406 | { | ||
| 407 | ✗ | clearscr(i); | |
| 408 | ✗ | } | |
| 409 | |||
| 410 | ✗ | setCurrScr(0); | |
| 411 | |||
| 412 | ✗ | if(newquest) | |
| 413 | { | ||
| 414 | ✗ | if(!reset_templates(false)) | |
| 415 | { | ||
| 416 | ✗ | jwin_alert("Error","Error resetting","template screens.",NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 417 | ✗ | } | |
| 418 | ✗ | } | |
| 419 | ✗ | } | |
| 420 | |||
| 421 | ✗ | return true; | |
| 422 | } | ||
| 423 | |||
| 424 | ✗ | MapCursor zmap::getCursor() const | |
| 425 | { | ||
| 426 | ✗ | return cursor; | |
| 427 | } | ||
| 428 | |||
| 429 | ✗ | void zmap::setCursor(MapCursor new_cursor) | |
| 430 | { | ||
| 431 | ✗ | if (cursor == new_cursor) | |
| 432 | ✗ | return; | |
| 433 | |||
| 434 | ✗ | optional<int> oldcolor; | |
| 435 | ✗ | if (screens) | |
| 436 | ✗ | oldcolor = getcolor(); | |
| 437 | |||
| 438 | ✗ | cursor = new_cursor; | |
| 439 | |||
| 440 | ✗ | int newcolor = getcolor(); | |
| 441 | ✗ | loadlvlpal(newcolor); | |
| 442 | ✗ | if (!oldcolor || *oldcolor != newcolor) | |
| 443 | ✗ | rebuild_trans_table(); | |
| 444 | |||
| 445 | ✗ | reset_combo_animations2(); | |
| 446 | ✗ | mmap_mark_dirty(); | |
| 447 | ✗ | regions_mark_dirty(); | |
| 448 | ✗ | refresh(rALL); | |
| 449 | ✗ | } | |
| 450 | |||
| 451 | ✗ | bool zmap::isValidPosition(ComboPosition pos) const | |
| 452 | { | ||
| 453 | ✗ | return pos.is_valid(cursor); | |
| 454 | } | ||
| 455 | |||
| 456 | ✗ | int zmap::getScreenForPosition(ComboPosition pos) const | |
| 457 | { | ||
| 458 | ✗ | return cursor.viewscr + pos.screen_offset(); | |
| 459 | } | ||
| 460 | |||
| 461 | ✗ | mapscr* zmap::CurrScr() | |
| 462 | { | ||
| 463 | ✗ | return screens+cursor.screen; | |
| 464 | } | ||
| 465 | ✗ | mapscr* zmap::Scr(int32_t scr) | |
| 466 | { | ||
| 467 | ✗ | return screens+scr; | |
| 468 | } | ||
| 469 | ✗ | mapscr* zmap::Scr(ComboPosition pos) | |
| 470 | { | ||
| 471 | ✗ | if (!pos.is_valid(cursor)) | |
| 472 | ✗ | return nullptr; | |
| 473 | |||
| 474 | ✗ | int screen_offset = pos.screen_offset(); | |
| 475 | ✗ | int screen = cursor.viewscr + screen_offset; | |
| 476 | ✗ | return AbsoluteScr(cursor.map, screen); | |
| 477 | ✗ | } | |
| 478 | ✗ | mapscr* zmap::Scr(ComboPosition pos, int layer) | |
| 479 | { | ||
| 480 | ✗ | int map = cursor.map; | |
| 481 | ✗ | int screen = cursor.viewscr + pos.screen_offset(); | |
| 482 | ✗ | if (layer) | |
| 483 | { | ||
| 484 | ✗ | mapscr* scr = Map.AbsoluteScr(map, screen); | |
| 485 | ✗ | map = scr->layermap[CurrentLayer-1]-1; | |
| 486 | ✗ | screen = scr->layerscreen[CurrentLayer-1]; | |
| 487 | ✗ | } | |
| 488 | |||
| 489 | ✗ | return AbsoluteScr(map, screen); | |
| 490 | } | ||
| 491 | ✗ | mapscr* zmap::ScrMakeValid(ComboPosition pos, int layer) | |
| 492 | { | ||
| 493 | ✗ | mapscr* scr = Scr(pos, layer); | |
| 494 | ✗ | if (scr && !(scr->valid&mVALID)) | |
| 495 | { | ||
| 496 | ✗ | scr->valid |= mVALID; | |
| 497 | ✗ | setcolor(Color, scr); | |
| 498 | ✗ | } | |
| 499 | ✗ | return scr; | |
| 500 | } | ||
| 501 | ✗ | mapscr* zmap::AbsoluteScr(int32_t scr) | |
| 502 | { | ||
| 503 | ✗ | if(unsigned(scr) >= MAPSCRS*getMapCount()) | |
| 504 | ✗ | return nullptr; | |
| 505 | ✗ | return &TheMaps[scr]; | |
| 506 | ✗ | } | |
| 507 | ✗ | mapscr* zmap::AbsoluteScr(int32_t map, int32_t scr) | |
| 508 | { | ||
| 509 | ✗ | if(map < 0 || map >= getMapCount() || scr < 0 || scr >= MAPSCRS) | |
| 510 | ✗ | return nullptr; | |
| 511 | ✗ | return AbsoluteScr((map*MAPSCRS)+scr); | |
| 512 | ✗ | } | |
| 513 | ✗ | mapscr* zmap::AbsoluteScrMakeValid(int32_t map, int32_t screen) | |
| 514 | { | ||
| 515 | ✗ | mapscr* scr = AbsoluteScr(map, screen); | |
| 516 | ✗ | if (scr && !(scr->valid&mVALID)) | |
| 517 | { | ||
| 518 | ✗ | scr->valid |= mVALID; | |
| 519 | ✗ | setcolor(Color, scr); | |
| 520 | ✗ | } | |
| 521 | ✗ | return scr; | |
| 522 | } | ||
| 523 | ✗ | void zmap::set_prvscr(int32_t map, int32_t scr) | |
| 524 | { | ||
| 525 | ✗ | prvscr=TheMaps[(map*MAPSCRS)+scr]; | |
| 526 | |||
| 527 | ✗ | for(int32_t i=0; i<6; i++) | |
| 528 | { | ||
| 529 | ✗ | if(prvscr.layermap[i]>0) | |
| 530 | { | ||
| 531 | ✗ | prvlayers[i]=TheMaps[(prvscr.layermap[i]-1)*MAPSCRS+prvscr.layerscreen[i]]; | |
| 532 | ✗ | } | |
| 533 | else | ||
| 534 | ✗ | prvlayers[i].valid = 0; | |
| 535 | ✗ | } | |
| 536 | |||
| 537 | ✗ | prv_map=map; | |
| 538 | ✗ | prv_scr=scr; | |
| 539 | ✗ | } | |
| 540 | 92 | int32_t zmap::getCurrMap() | |
| 541 | { | ||
| 542 | 92 | return cursor.map; | |
| 543 | } | ||
| 544 | 21 | void zmap::regions_mark_dirty() | |
| 545 | { | ||
| 546 | 21 | regions_dirty = true; | |
| 547 | 21 | } | |
| 548 | ✗ | void zmap::regions_refresh() | |
| 549 | { | ||
| 550 | ✗ | if (!regions_dirty) | |
| 551 | ✗ | return; | |
| 552 | |||
| 553 | ✗ | regions_dirty = false; | |
| 554 | ✗ | region_descriptions.clear(); | |
| 555 | |||
| 556 | ✗ | current_map_region_ids = Regions[cursor.map].get_all_region_ids(); | |
| 557 | ✗ | if (!get_all_region_descriptions(region_descriptions, current_map_region_ids)) | |
| 558 | ✗ | region_descriptions.clear(); | |
| 559 | ✗ | } | |
| 560 | ✗ | const std::vector<region_description>& zmap::get_region_descriptions() | |
| 561 | { | ||
| 562 | ✗ | regions_refresh(); | |
| 563 | ✗ | return region_descriptions; | |
| 564 | } | ||
| 565 | ✗ | bool zmap::is_region(int screen) | |
| 566 | { | ||
| 567 | ✗ | if (screen < 0 || screen >= 128) | |
| 568 | ✗ | return false; | |
| 569 | |||
| 570 | ✗ | regions_refresh(); | |
| 571 | ✗ | return current_map_region_ids[screen]; | |
| 572 | ✗ | } | |
| 573 | ✗ | bool zmap::isDark(int scr) | |
| 574 | { | ||
| 575 | ✗ | return (screens[scr].flags&fDARK)!=0; | |
| 576 | } | ||
| 577 | ✗ | bool zmap::isValid(int32_t scr) | |
| 578 | { | ||
| 579 | ✗ | return (screens[scr].valid&mVALID)!=0; | |
| 580 | } | ||
| 581 | ✗ | bool zmap::isValid(int32_t map, int32_t scr) | |
| 582 | { | ||
| 583 | ✗ | return (AbsoluteScr(map, scr)->valid&mVALID)!=0; | |
| 584 | } | ||
| 585 | |||
| 586 | 11 | void zmap::setCurrMap(int32_t index) | |
| 587 | { | ||
| 588 | 11 | optional<int> oldcolor; | |
| 589 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if(screens) |
| 590 | ✗ | oldcolor = getcolor(); | |
| 591 | 11 | scrpos[cursor.map] = cursor.screen; | |
| 592 | 11 | scrview[cursor.map] = cursor.viewscr; | |
| 593 | 11 | cursor.map = bound(index,0,map_count); | |
| 594 | 11 | screens = &TheMaps[cursor.map*MAPSCRS]; | |
| 595 | |||
| 596 | 11 | cursor.viewscr = scrview[cursor.map]; | |
| 597 | 11 | cursor.setScreen(scrpos[cursor.map]); | |
| 598 | |||
| 599 | 11 | int newcolor = getcolor(); | |
| 600 | 11 | loadlvlpal(newcolor); | |
| 601 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11 | if(!oldcolor || *oldcolor != newcolor) |
| 602 | 11 | rebuild_trans_table(); | |
| 603 | |||
| 604 | 11 | reset_combo_animations2(); | |
| 605 | 11 | mmap_mark_dirty(); | |
| 606 | 11 | regions_mark_dirty(); | |
| 607 | 11 | } | |
| 608 | |||
| 609 | 20 | int32_t zmap::getCurrScr() | |
| 610 | { | ||
| 611 | 20 | return cursor.screen; | |
| 612 | } | ||
| 613 | 11 | void zmap::setCurrScr(int32_t scr) | |
| 614 | { | ||
| 615 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
|
11 | if (scr == cursor.screen) |
| 616 | 1 | return; | |
| 617 | |||
| 618 | 10 | int32_t oldcolor=getcolor(); | |
| 619 | 10 | cursor.setScreen(scr); | |
| 620 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if (!(screens[cursor.screen].valid&mVALID)) |
| 621 | { | ||
| 622 | ✗ | oldcolor=-1; | |
| 623 | ✗ | } | |
| 624 | |||
| 625 | 10 | int32_t newcolor=getcolor(); | |
| 626 | 10 | loadlvlpal(newcolor); | |
| 627 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
|
10 | if (newcolor!=oldcolor) |
| 628 | { | ||
| 629 | 9 | rebuild_trans_table(); | |
| 630 | 9 | } | |
| 631 | |||
| 632 | 10 | reset_combo_animations2(); | |
| 633 | 10 | setlayertarget(); | |
| 634 | 10 | mmap_mark_dirty(); | |
| 635 | 10 | regions_mark_dirty(); | |
| 636 | 11 | } | |
| 637 | |||
| 638 | ✗ | int32_t zmap::getViewScr() | |
| 639 | { | ||
| 640 | ✗ | return cursor.viewscr; | |
| 641 | } | ||
| 642 | |||
| 643 | 11 | void zmap::setViewSize(int32_t size) | |
| 644 | { | ||
| 645 | 11 | cursor.setSize(size); | |
| 646 | 11 | } | |
| 647 | |||
| 648 | 8 | int32_t zmap::getViewSize() | |
| 649 | { | ||
| 650 | 8 | return cursor.size; | |
| 651 | } | ||
| 652 | |||
| 653 | 10 | void zmap::setlayertarget() | |
| 654 | { | ||
| 655 | 10 | layer_target_map = 0; | |
| 656 | 10 | layer_target_multiple = 0; | |
| 657 | |||
| 658 |
2/2✓ Branch 0 taken 53 times.
✓ Branch 1 taken 10 times.
|
63 | for(int32_t m=0; m<getMapCount(); ++m) |
| 659 | { | ||
| 660 |
2/2✓ Branch 0 taken 7208 times.
✓ Branch 1 taken 53 times.
|
7261 | for(int32_t s=0; s<MAPSCRS; ++s) |
| 661 | { | ||
| 662 | 7208 | int32_t i=(m*MAPSCRS+s); | |
| 663 | 7208 | mapscr *ts=&TheMaps[i]; | |
| 664 | |||
| 665 | // Search through each layer | ||
| 666 |
2/2✓ Branch 0 taken 43248 times.
✓ Branch 1 taken 7208 times.
|
50456 | for(int32_t w=0; w<6; ++w) |
| 667 | { | ||
| 668 |
3/4✓ Branch 0 taken 17 times.
✓ Branch 1 taken 43231 times.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
|
43248 | if(ts->layerscreen[w]==cursor.screen && (ts->layermap[w]-1)==cursor.map) |
| 669 | { | ||
| 670 | ✗ | if(layer_target_map > 0) | |
| 671 | { | ||
| 672 | ✗ | layer_target_multiple += 1; | |
| 673 | ✗ | continue; | |
| 674 | } | ||
| 675 | |||
| 676 | ✗ | layer_target_map = m+1; | |
| 677 | ✗ | layer_target_scr = s; | |
| 678 | ✗ | } | |
| 679 | 43248 | } | |
| 680 | 7208 | } | |
| 681 | 53 | } | |
| 682 | 10 | } | |
| 683 | |||
| 684 | ✗ | void zmap::setcolor(int color, mapscr* scr) | |
| 685 | { | ||
| 686 | ✗ | if (!scr) scr = CurrScr(); | |
| 687 | ✗ | scr->valid |= mVALID; | |
| 688 | ✗ | scr->color = color; | |
| 689 | |||
| 690 | ✗ | if(Color!=color) | |
| 691 | { | ||
| 692 | ✗ | Color = color; | |
| 693 | ✗ | loadlvlpal(color); | |
| 694 | ✗ | rebuild_trans_table(); | |
| 695 | ✗ | } | |
| 696 | |||
| 697 | ✗ | mmap_mark_dirty(); | |
| 698 | ✗ | } | |
| 699 | |||
| 700 | 31 | int32_t zmap::getcolor() | |
| 701 | { | ||
| 702 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
|
31 | if(prv_mode) |
| 703 | { | ||
| 704 | ✗ | return prvscr.color; | |
| 705 | } | ||
| 706 | |||
| 707 | 31 | return screens[cursor.screen].color; | |
| 708 | 31 | } | |
| 709 | |||
| 710 | ✗ | void zmap::resetflags() | |
| 711 | { | ||
| 712 | ✗ | byte *di=&(screens[cursor.screen].valid); | |
| 713 | |||
| 714 | ✗ | for(int32_t i=1; i<48; i++) | |
| 715 | { | ||
| 716 | ✗ | *(di+i)=0; | |
| 717 | ✗ | } | |
| 718 | ✗ | } | |
| 719 | |||
| 720 | ✗ | word zmap::tcmbdat(int32_t pos) | |
| 721 | { | ||
| 722 | ✗ | return screens[TEMPLATE].data[pos]; | |
| 723 | } | ||
| 724 | |||
| 725 | ✗ | word zmap::tcmbcset(int32_t pos) | |
| 726 | { | ||
| 727 | ✗ | return screens[TEMPLATE].cset[pos]; | |
| 728 | } | ||
| 729 | |||
| 730 | ✗ | int32_t zmap::tcmbflag(int32_t pos) | |
| 731 | { | ||
| 732 | ✗ | return screens[TEMPLATE].sflag[pos]; | |
| 733 | } | ||
| 734 | |||
| 735 | ✗ | word zmap::tcmbdat2(int32_t pos) | |
| 736 | { | ||
| 737 | ✗ | return screens[TEMPLATE2].data[pos]; | |
| 738 | } | ||
| 739 | |||
| 740 | ✗ | word zmap::tcmbcset2(int32_t pos) | |
| 741 | { | ||
| 742 | ✗ | return screens[TEMPLATE2].cset[pos]; | |
| 743 | } | ||
| 744 | |||
| 745 | ✗ | int32_t zmap::tcmbflag2(int32_t pos) | |
| 746 | { | ||
| 747 | ✗ | return screens[TEMPLATE2].sflag[pos]; | |
| 748 | } | ||
| 749 | |||
| 750 | ✗ | void zmap::TemplateAll() | |
| 751 | { | ||
| 752 | ✗ | StartListCommand(); | |
| 753 | ✗ | for(int32_t i=0; i<128; i++) | |
| 754 | { | ||
| 755 | ✗ | if((screens[i].valid&mVALID) && isDungeon(i)) | |
| 756 | ✗ | DoTemplateCommand(-1, -1, i); | |
| 757 | ✗ | } | |
| 758 | ✗ | FinishListCommand(); | |
| 759 | ✗ | } | |
| 760 | |||
| 761 | ✗ | void zmap::Template(int32_t floorcombo, int32_t floorcset, int32_t scr) | |
| 762 | { | ||
| 763 | ✗ | if(scr==TEMPLATE) | |
| 764 | ✗ | return; | |
| 765 | |||
| 766 | ✗ | if(!(screens[scr].valid&mVALID)) | |
| 767 | ✗ | screens[scr].color=Color; | |
| 768 | |||
| 769 | ✗ | screens[scr].valid|=mVALID; | |
| 770 | |||
| 771 | ✗ | for(int32_t i=0; i<32; i++) | |
| 772 | { | ||
| 773 | ✗ | screens[scr].data[i]=screens[TEMPLATE].data[i]; | |
| 774 | ✗ | screens[scr].cset[i]=screens[TEMPLATE].cset[i]; | |
| 775 | ✗ | screens[scr].sflag[i]=screens[TEMPLATE].sflag[i]; | |
| 776 | ✗ | } | |
| 777 | |||
| 778 | ✗ | for(int32_t i=144; i<176; i++) | |
| 779 | { | ||
| 780 | ✗ | screens[scr].data[i]=screens[TEMPLATE].data[i]; | |
| 781 | ✗ | screens[scr].cset[i]=screens[TEMPLATE].cset[i]; | |
| 782 | ✗ | screens[scr].sflag[i]=screens[TEMPLATE].sflag[i]; | |
| 783 | ✗ | } | |
| 784 | |||
| 785 | ✗ | for(int32_t y=2; y<=9; y++) | |
| 786 | { | ||
| 787 | ✗ | int32_t j=y<<4; | |
| 788 | ✗ | screens[scr].data[j]=screens[TEMPLATE].data[j]; | |
| 789 | ✗ | screens[scr].cset[j]=screens[TEMPLATE].cset[j]; | |
| 790 | ✗ | screens[scr].sflag[j]=screens[TEMPLATE].sflag[j]; | |
| 791 | ✗ | ++j; | |
| 792 | ✗ | screens[scr].data[j]=screens[TEMPLATE].data[j]; | |
| 793 | ✗ | screens[scr].cset[j]=screens[TEMPLATE].cset[j]; | |
| 794 | ✗ | screens[scr].sflag[j]=screens[TEMPLATE].sflag[j]; | |
| 795 | ✗ | ++j; | |
| 796 | ✗ | j+=12; | |
| 797 | ✗ | screens[scr].data[j]=screens[TEMPLATE].data[j]; | |
| 798 | ✗ | screens[scr].cset[j]=screens[TEMPLATE].cset[j]; | |
| 799 | ✗ | screens[scr].sflag[j]=screens[TEMPLATE].sflag[j]; | |
| 800 | ✗ | ++j; | |
| 801 | ✗ | screens[scr].data[j]=screens[TEMPLATE].data[j]; | |
| 802 | ✗ | screens[scr].cset[j]=screens[TEMPLATE].cset[j]; | |
| 803 | |||
| 804 | ✗ | screens[scr].sflag[j]=screens[TEMPLATE].sflag[j]; | |
| 805 | ✗ | ++j; | |
| 806 | ✗ | } | |
| 807 | |||
| 808 | ✗ | if(floorcombo!=-1) | |
| 809 | { | ||
| 810 | ✗ | for(int32_t y=2; y<9; y++) | |
| 811 | ✗ | for(int32_t x=2; x<14; x++) | |
| 812 | { | ||
| 813 | ✗ | int32_t i=(y<<4)+x; | |
| 814 | ✗ | screens[scr].data[i] = floorcombo; | |
| 815 | ✗ | screens[scr].cset[i] = floorcset; | |
| 816 | ✗ | } | |
| 817 | ✗ | } | |
| 818 | |||
| 819 | ✗ | for(int32_t i=0; i<4; i++) | |
| 820 | ✗ | putdoor(scr,i,screens[scr].door[i]); | |
| 821 | ✗ | } | |
| 822 | |||
| 823 | |||
| 824 | ✗ | void zmap::clearscr(int32_t scr) | |
| 825 | { | ||
| 826 | ✗ | screens[scr].zero_memory(); | |
| 827 | ✗ | screens[scr].valid=mVERSION; | |
| 828 | ✗ | for(int q = 0; q < 6; ++q) | |
| 829 | { | ||
| 830 | ✗ | auto layer = map_autolayers[cursor.map*6+q]; | |
| 831 | ✗ | screens[scr].layermap[q] = layer; | |
| 832 | ✗ | screens[scr].layerscreen[q] = layer ? scr : 0; | |
| 833 | ✗ | } | |
| 834 | ✗ | mmap_mark_dirty(); | |
| 835 | ✗ | } | |
| 836 | |||
| 837 | const char *loaderror[] = | ||
| 838 | { | ||
| 839 | |||
| 840 | "OK","File not found","Incomplete data", | ||
| 841 | "Invalid version","Invalid file" | ||
| 842 | |||
| 843 | }; | ||
| 844 | |||
| 845 | ✗ | int32_t zmap::load(const char *path) | |
| 846 | { | ||
| 847 | ✗ | PACKFILE *f=pack_fopen_password(path,F_READ, ""); | |
| 848 | |||
| 849 | ✗ | if(!f) | |
| 850 | ✗ | return 1; | |
| 851 | |||
| 852 | |||
| 853 | int16_t version; | ||
| 854 | byte build; | ||
| 855 | |||
| 856 | //get the version | ||
| 857 | ✗ | if(!p_igetw(&version,f)) | |
| 858 | { | ||
| 859 | ✗ | goto file_error; | |
| 860 | } | ||
| 861 | |||
| 862 | //get the build | ||
| 863 | ✗ | if(!p_getc(&build,f)) | |
| 864 | { | ||
| 865 | ✗ | goto file_error; | |
| 866 | } | ||
| 867 | |||
| 868 | ✗ | for(int32_t i=0; i<MAPSCRS; i++) | |
| 869 | { | ||
| 870 | ✗ | mapscr tmpimportscr; | |
| 871 | ✗ | tmpimportscr.zero_memory(); | |
| 872 | ✗ | if(readmapscreen(f,&header,&tmpimportscr,version)==qe_invalid) | |
| 873 | { | ||
| 874 | ✗ | al_trace("failed zmap::load\n"); | |
| 875 | ✗ | goto file_error; | |
| 876 | } | ||
| 877 | |||
| 878 | ✗ | switch(ImportMapBias) | |
| 879 | { | ||
| 880 | case 0: | ||
| 881 | ✗ | *(screens+i) = tmpimportscr; | |
| 882 | ✗ | break; | |
| 883 | |||
| 884 | case 1: | ||
| 885 | ✗ | if(!(screens[i].valid&mVALID)) | |
| 886 | { | ||
| 887 | ✗ | *(screens+i) = tmpimportscr; | |
| 888 | ✗ | } | |
| 889 | ✗ | break; | |
| 890 | |||
| 891 | case 2: | ||
| 892 | ✗ | if(tmpimportscr.valid&mVALID) | |
| 893 | { | ||
| 894 | ✗ | *(screens+i) = tmpimportscr; | |
| 895 | ✗ | } | |
| 896 | ✗ | break; | |
| 897 | } | ||
| 898 | ✗ | } | |
| 899 | |||
| 900 | |||
| 901 | ✗ | pack_fclose(f); | |
| 902 | |||
| 903 | ✗ | setCurrScr(0); | |
| 904 | ✗ | mmap_mark_dirty(); | |
| 905 | ✗ | regions_mark_dirty(); | |
| 906 | ✗ | return 0; | |
| 907 | |||
| 908 | file_error: | ||
| 909 | ✗ | pack_fclose(f); | |
| 910 | ✗ | clearmap(false); | |
| 911 | ✗ | return 2; | |
| 912 | ✗ | } | |
| 913 | |||
| 914 | ✗ | int32_t zmap::save(const char *path) | |
| 915 | { | ||
| 916 | ✗ | PACKFILE *f=pack_fopen_password(path,F_WRITE, ""); | |
| 917 | |||
| 918 | ✗ | if(!f) | |
| 919 | ✗ | return 1; | |
| 920 | |||
| 921 | ✗ | if(!p_iputw(V_MAPS,f)) | |
| 922 | { | ||
| 923 | ✗ | pack_fclose(f); | |
| 924 | ✗ | return 3; | |
| 925 | } | ||
| 926 | |||
| 927 | // This was the "build number", but that's totally useless here. Keep this junk byte | ||
| 928 | // so as not to totally break exports between ZC versions. | ||
| 929 | ✗ | if(!p_putc(0,f)) | |
| 930 | { | ||
| 931 | ✗ | pack_fclose(f); | |
| 932 | ✗ | return 3; | |
| 933 | } | ||
| 934 | |||
| 935 | ✗ | for(int32_t i=0; i<MAPSCRS; i++) | |
| 936 | { | ||
| 937 | ✗ | if(writemapscreen(f,this->getCurrMap(),i) == qe_invalid) | |
| 938 | { | ||
| 939 | ✗ | pack_fclose(f); | |
| 940 | ✗ | return 2; | |
| 941 | } | ||
| 942 | ✗ | } | |
| 943 | |||
| 944 | ✗ | pack_fclose(f); | |
| 945 | ✗ | return 0; | |
| 946 | ✗ | } | |
| 947 | |||
| 948 | |||
| 949 | ✗ | bool zmap::ishookshottable(int32_t bx, int32_t by, int32_t i) | |
| 950 | { | ||
| 951 | // Hookshots can be blocked by solid combos on all 3 ground layers. | ||
| 952 | ✗ | const newcombo* c = &combobuf[MAPCOMBO(bx,by)]; | |
| 953 | |||
| 954 | ✗ | if(c->type == cHOOKSHOTONLY || c->type == cLADDERHOOKSHOT) | |
| 955 | ✗ | return true; | |
| 956 | ✗ | if (c->walk&(1<<i)) | |
| 957 | ✗ | return false; | |
| 958 | |||
| 959 | ✗ | for(int32_t k=0; k<2; k++) | |
| 960 | { | ||
| 961 | ✗ | c = &combobuf[MAPCOMBO2(k+1,bx,by)]; | |
| 962 | |||
| 963 | ✗ | if(c->type != cHOOKSHOTONLY && c->type != cLADDERHOOKSHOT && c->walk&(1<<i)) | |
| 964 | { | ||
| 965 | ✗ | return false; | |
| 966 | } | ||
| 967 | ✗ | } | |
| 968 | |||
| 969 | ✗ | return true; | |
| 970 | ✗ | } | |
| 971 | |||
| 972 | ✗ | bool zmap::ishookshottable(int32_t map, int32_t screen, int32_t bx, int32_t by, int32_t i) | |
| 973 | { | ||
| 974 | // Hookshots can be blocked by solid combos on all 3 ground layers. | ||
| 975 | ✗ | const newcombo* c = &combobuf[MAPCOMBO3(map, screen, -1, bx,by)]; | |
| 976 | |||
| 977 | ✗ | if(c->type == cHOOKSHOTONLY || c->type == cLADDERHOOKSHOT) | |
| 978 | ✗ | return true; | |
| 979 | ✗ | if (c->walk&(1<<i)) | |
| 980 | ✗ | return false; | |
| 981 | |||
| 982 | ✗ | for(int32_t k=0; k<2; k++) | |
| 983 | { | ||
| 984 | ✗ | c = &combobuf[MAPCOMBO3(map, screen, k+1,bx,by)]; | |
| 985 | |||
| 986 | ✗ | if(c->type != cHOOKSHOTONLY && c->type != cLADDERHOOKSHOT && c->walk&(1<<i)) | |
| 987 | { | ||
| 988 | ✗ | return false; | |
| 989 | } | ||
| 990 | ✗ | } | |
| 991 | |||
| 992 | ✗ | return true; | |
| 993 | ✗ | } | |
| 994 | |||
| 995 | ✗ | bool zmap::isstepable(int32_t combo) | |
| 996 | { | ||
| 997 | // This is kind of odd but it's true to the engine (see maps.cpp) | ||
| 998 | ✗ | return (combo_class_buf[combobuf[combo].type].ladder_pass); | |
| 999 | } | ||
| 1000 | |||
| 1001 | // Returns the letter of the warp combo. | ||
| 1002 | ✗ | int32_t zmap::warpindex(int32_t combo) | |
| 1003 | { | ||
| 1004 | ✗ | switch(combobuf[combo].type) | |
| 1005 | { | ||
| 1006 | case cCAVE: | ||
| 1007 | case cPIT: | ||
| 1008 | case cSTAIR: | ||
| 1009 | case cCAVE2: | ||
| 1010 | case cSWIMWARP: | ||
| 1011 | case cDIVEWARP: | ||
| 1012 | case cSWARPA: | ||
| 1013 | ✗ | return 0; | |
| 1014 | |||
| 1015 | case cCAVEB: | ||
| 1016 | case cPITB: | ||
| 1017 | case cSTAIRB: | ||
| 1018 | case cCAVE2B: | ||
| 1019 | case cSWIMWARPB: | ||
| 1020 | case cDIVEWARPB: | ||
| 1021 | case cSWARPB: | ||
| 1022 | ✗ | return 1; | |
| 1023 | |||
| 1024 | case cCAVEC: | ||
| 1025 | case cPITC: | ||
| 1026 | case cSTAIRC: | ||
| 1027 | case cCAVE2C: | ||
| 1028 | case cSWIMWARPC: | ||
| 1029 | case cDIVEWARPC: | ||
| 1030 | case cSWARPC: | ||
| 1031 | ✗ | return 2; | |
| 1032 | |||
| 1033 | case cCAVED: | ||
| 1034 | case cPITD: | ||
| 1035 | case cSTAIRD: | ||
| 1036 | case cCAVE2D: | ||
| 1037 | case cSWIMWARPD: | ||
| 1038 | case cDIVEWARPD: | ||
| 1039 | case cSWARPD: | ||
| 1040 | ✗ | return 3; | |
| 1041 | |||
| 1042 | case cPITR: | ||
| 1043 | case cSTAIRR: | ||
| 1044 | case cSWARPR: | ||
| 1045 | ✗ | return 4; | |
| 1046 | } | ||
| 1047 | |||
| 1048 | ✗ | return -1; | |
| 1049 | |||
| 1050 | ✗ | } | |
| 1051 | |||
| 1052 | ✗ | void draw_ladder(BITMAP* dest, int32_t x, int32_t y, int32_t c, bool top = false) | |
| 1053 | { | ||
| 1054 | ✗ | if(top) | |
| 1055 | ✗ | line(dest,x,y,x+15,y,c); | |
| 1056 | ✗ | rectfill(dest,x,y,x+3,y+15,c); | |
| 1057 | ✗ | rectfill(dest,x+12,y,x+15,y+15,c); | |
| 1058 | ✗ | rectfill(dest,x+4,y+2,x+11,y+5,c); | |
| 1059 | ✗ | rectfill(dest,x+4,y+10,x+11,y+13,c); | |
| 1060 | ✗ | } | |
| 1061 | |||
| 1062 | ✗ | void draw_platform(BITMAP* dest, int32_t x, int32_t y, int32_t c) | |
| 1063 | { | ||
| 1064 | ✗ | line(dest,x,y,x+15,y,c); | |
| 1065 | ✗ | } | |
| 1066 | |||
| 1067 | ✗ | void zmap::put_walkflags_layered(BITMAP *dest,int32_t x,int32_t y,int32_t pos,int32_t layer) | |
| 1068 | { | ||
| 1069 | ✗ | int32_t cx = COMBOX(pos); | |
| 1070 | ✗ | int32_t cy = COMBOY(pos); | |
| 1071 | |||
| 1072 | ✗ | newcombo const& c = combobuf[ MAPCOMBO2(layer,cx,cy) ]; | |
| 1073 | |||
| 1074 | ✗ | if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) return; | |
| 1075 | |||
| 1076 | ✗ | int32_t bridgedetected = 0; | |
| 1077 | |||
| 1078 | ✗ | for(int32_t i=0; i<4; i++) | |
| 1079 | { | ||
| 1080 | ✗ | int32_t tx=((i&2)<<2)+x; | |
| 1081 | ✗ | int32_t ty=((i&1)<<3)+y; | |
| 1082 | ✗ | int32_t tx2=((i&2)<<2)+cx; | |
| 1083 | ✗ | int32_t ty2=((i&1)<<3)+cy; | |
| 1084 | ✗ | for (int32_t m = layer; m <= 1; m++) | |
| 1085 | { | ||
| 1086 | ✗ | if (get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1087 | { | ||
| 1088 | ✗ | if (combobuf[MAPCOMBO2(m,tx2,ty2)].type == cBRIDGE && !(combobuf[MAPCOMBO2(m,tx2,ty2)].walk&(1<<i))) | |
| 1089 | { | ||
| 1090 | ✗ | bridgedetected |= (1<<i); | |
| 1091 | ✗ | } | |
| 1092 | ✗ | } | |
| 1093 | else | ||
| 1094 | { | ||
| 1095 | ✗ | if (combobuf[MAPCOMBO2(m,tx2,ty2)].type == cBRIDGE && (combobuf[MAPCOMBO2(m,tx2,ty2)].walk&(0x10<<i))) | |
| 1096 | { | ||
| 1097 | ✗ | bridgedetected |= (1<<i); | |
| 1098 | ✗ | } | |
| 1099 | } | ||
| 1100 | ✗ | } | |
| 1101 | ✗ | if (bridgedetected & (1<<i)) | |
| 1102 | { | ||
| 1103 | ✗ | if (i >= 3) break; | |
| 1104 | ✗ | else continue; | |
| 1105 | } | ||
| 1106 | ✗ | if ((c.walk&(1<<(i+4))) && ((c.walk&(1<<i) && ((c.usrflags&cflag4)) && c.type == cWATER) || c.type == cSHALLOWWATER)) | |
| 1107 | { | ||
| 1108 | ✗ | for(int32_t k=0; k<8; k+=2) | |
| 1109 | ✗ | for(int32_t j=0; j<8; j+=2) | |
| 1110 | ✗ | if(((k+j)/2)%2) rectfill(dest,tx+k,ty+j,tx+k+1,ty+j+1,vc(11)); | |
| 1111 | ✗ | } | |
| 1112 | ✗ | if (!(c.walk&(1<<i) && ((c.usrflags&cflag3) || (c.usrflags&cflag4))) && (layer==-1 || (get_qr(qr_WATER_ON_LAYER_1) && layer == 0) || (get_qr(qr_WATER_ON_LAYER_2) && layer == 1)) && combo_class_buf[c.type].water!=0 && get_qr(qr_DROWN)) | |
| 1113 | ✗ | rectfill(dest,tx,ty,tx+7,ty+7,vc(11)); | |
| 1114 | |||
| 1115 | ✗ | if(c.walk&(1<<i) && !(combo_class_buf[c.type].water!=0 && ((c.usrflags&cflag3) || (c.usrflags&cflag4)))) | |
| 1116 | { | ||
| 1117 | ✗ | if(c.type==cLADDERHOOKSHOT && isstepable(MAPCOMBO(cx,cy)) && ishookshottable(cx,cy,i)) | |
| 1118 | { | ||
| 1119 | ✗ | for(int32_t k=0; k<8; k+=2) | |
| 1120 | ✗ | for(int32_t j=0; j<8; j+=2) | |
| 1121 | ✗ | rectfill(dest,tx+k,ty+j,tx+k+1,ty+j+1,vc(6+((k+j)/2)%2)); | |
| 1122 | ✗ | } | |
| 1123 | else | ||
| 1124 | { | ||
| 1125 | ✗ | int32_t color = COLOR_SOLID; | |
| 1126 | |||
| 1127 | ✗ | if(isstepable(MAPCOMBO(cx,cy)) && (!get_qr(qr_NO_SOLID_SWIM) || (combo_class_buf[combobuf[MAPCOMBO(cx,cy)].type].water==0 && combo_class_buf[c.type].water==0))) | |
| 1128 | ✗ | color=vc(6); | |
| 1129 | ✗ | else if((c.type==cHOOKSHOTONLY || c.type==cLADDERHOOKSHOT) && ishookshottable(cx,cy,i)) | |
| 1130 | ✗ | color=vc(7); | |
| 1131 | |||
| 1132 | ✗ | rectfill(dest,tx,ty,tx+7,ty+7,color); | |
| 1133 | } | ||
| 1134 | ✗ | } | |
| 1135 | ✗ | } | |
| 1136 | |||
| 1137 | ✗ | bridgedetected = 0; | |
| 1138 | ✗ | for(int32_t i=0; i<4; i++) | |
| 1139 | { | ||
| 1140 | ✗ | int32_t tx2=((i&2)<<2)+cx; | |
| 1141 | ✗ | int32_t ty2=((i&1)<<3)+cy; | |
| 1142 | ✗ | for (int32_t m = 0; m <= 1; m++) | |
| 1143 | { | ||
| 1144 | ✗ | if (get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1145 | { | ||
| 1146 | ✗ | if (combobuf[MAPCOMBO2(m,tx2,ty2)].type == cBRIDGE && !(combobuf[MAPCOMBO2(m,tx2,ty2)].walk&(1<<i))) | |
| 1147 | { | ||
| 1148 | ✗ | bridgedetected |= (1<<i); | |
| 1149 | ✗ | } | |
| 1150 | ✗ | } | |
| 1151 | else | ||
| 1152 | { | ||
| 1153 | ✗ | if (combobuf[MAPCOMBO2(m,tx2,ty2)].type == cBRIDGE && (combobuf[MAPCOMBO2(m,tx2,ty2)].walk&(0x10<<i))) | |
| 1154 | { | ||
| 1155 | ✗ | bridgedetected |= (1<<i); | |
| 1156 | ✗ | } | |
| 1157 | } | ||
| 1158 | ✗ | } | |
| 1159 | ✗ | } | |
| 1160 | |||
| 1161 | // Draw damage combos | ||
| 1162 | ✗ | newcombo const& c0 = combobuf[MAPCOMBO2(-1,cx,cy)]; | |
| 1163 | ✗ | newcombo const& c1 = combobuf[MAPCOMBO2(0,cx,cy)]; | |
| 1164 | ✗ | newcombo const& c2 = combobuf[MAPCOMBO2(1,cx,cy)]; | |
| 1165 | ✗ | bool dmg = combo_class_buf[c0.type].modify_hp_amount | |
| 1166 | ✗ | || combo_class_buf[c1.type].modify_hp_amount | |
| 1167 | ✗ | || combo_class_buf[c2.type].modify_hp_amount; | |
| 1168 | |||
| 1169 | ✗ | if (combo_class_buf[c2.type].modify_hp_amount) bridgedetected = 0; | |
| 1170 | |||
| 1171 | ✗ | if(dmg) | |
| 1172 | { | ||
| 1173 | ✗ | if (bridgedetected <= 0) | |
| 1174 | { | ||
| 1175 | ✗ | for(int32_t k=0; k<16; k+=2) | |
| 1176 | ✗ | for(int32_t j=0; j<16; j+=2) | |
| 1177 | ✗ | if(((k+j)/2)%2) | |
| 1178 | ✗ | rectfill(dest,x+k,y+j,x+k+1,y+j+1,vc(14)); | |
| 1179 | ✗ | } | |
| 1180 | else | ||
| 1181 | { | ||
| 1182 | ✗ | for(int32_t i=0; i<4; i++) | |
| 1183 | { | ||
| 1184 | ✗ | if (!(bridgedetected & (1<<i))) | |
| 1185 | { | ||
| 1186 | ✗ | int32_t tx=((i&2)<<2)+x; | |
| 1187 | ✗ | int32_t ty=((i&1)<<3)+y; | |
| 1188 | ✗ | for(int32_t k=0; k<8; k+=2) | |
| 1189 | ✗ | for(int32_t j=0; j<8; j+=2) | |
| 1190 | ✗ | if(((k+j)/2)%2) | |
| 1191 | ✗ | rectfill(dest,tx+k,ty+j,tx+k+1,ty+j+1,vc(14)); | |
| 1192 | ✗ | } | |
| 1193 | ✗ | } | |
| 1194 | } | ||
| 1195 | ✗ | } | |
| 1196 | |||
| 1197 | ✗ | if(c.type == cSLOPE) | |
| 1198 | { | ||
| 1199 | ✗ | slope_info s(c, x, y); | |
| 1200 | ✗ | s.draw(dest, 0, 0, COLOR_SLOPE); | |
| 1201 | ✗ | } | |
| 1202 | ✗ | auto fl0 = MAPFLAG2(-1,cx,cy); | |
| 1203 | ✗ | auto fl1 = MAPFLAG2(0,cx,cy); | |
| 1204 | ✗ | auto fl2 = MAPFLAG2(1,cx,cy); | |
| 1205 | ✗ | if(fl0 == mfSIDEVIEWLADDER || fl1 == mfSIDEVIEWLADDER || fl2 == mfSIDEVIEWLADDER | |
| 1206 | ✗ | || c0.flag == mfSIDEVIEWLADDER || c1.flag == mfSIDEVIEWLADDER || c2.flag == mfSIDEVIEWLADDER) | |
| 1207 | { | ||
| 1208 | ✗ | bool top = false; | |
| 1209 | ✗ | if(cy) | |
| 1210 | { | ||
| 1211 | ✗ | top = true; | |
| 1212 | ✗ | if(combobuf[MAPCOMBO2(-1,cx,cy-16)].flag == mfSIDEVIEWLADDER | |
| 1213 | ✗ | || combobuf[MAPCOMBO2(0,cx,cy-16)].flag == mfSIDEVIEWLADDER | |
| 1214 | ✗ | || combobuf[MAPCOMBO2(1,cx,cy-16)].flag == mfSIDEVIEWLADDER | |
| 1215 | ✗ | || MAPFLAG2(-1,cx,cy) == mfSIDEVIEWLADDER | |
| 1216 | ✗ | || MAPFLAG2(0,cx,cy) == mfSIDEVIEWLADDER | |
| 1217 | ✗ | || MAPFLAG2(1,cx,cy) == mfSIDEVIEWLADDER) | |
| 1218 | { | ||
| 1219 | ✗ | top = false; | |
| 1220 | ✗ | } | |
| 1221 | ✗ | } | |
| 1222 | ✗ | draw_ladder(dest,x,y,COLOR_LADDER,top); | |
| 1223 | ✗ | } | |
| 1224 | ✗ | else if(fl0 == mfSIDEVIEWPLATFORM || fl1 == mfSIDEVIEWPLATFORM || fl2 == mfSIDEVIEWPLATFORM | |
| 1225 | ✗ | || c0.flag == mfSIDEVIEWPLATFORM || c1.flag == mfSIDEVIEWPLATFORM || c2.flag == mfSIDEVIEWPLATFORM) | |
| 1226 | { | ||
| 1227 | ✗ | draw_platform(dest,x,y,COLOR_LADDER); | |
| 1228 | ✗ | } | |
| 1229 | ✗ | } | |
| 1230 | |||
| 1231 | ✗ | void zmap::put_walkflags_layered_external(BITMAP *dest,int32_t x,int32_t y,int32_t pos,int32_t layer, int32_t map, int32_t screen) | |
| 1232 | { | ||
| 1233 | ✗ | int32_t cx = COMBOX(pos); | |
| 1234 | ✗ | int32_t cy = COMBOY(pos); | |
| 1235 | |||
| 1236 | ✗ | if (screen < 0) return; | |
| 1237 | ✗ | if (map < 0) return; | |
| 1238 | |||
| 1239 | ✗ | newcombo const& c = combobuf[MAPCOMBO3(map, screen, layer, pos)]; | |
| 1240 | |||
| 1241 | ✗ | if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) return; | |
| 1242 | |||
| 1243 | ✗ | int32_t bridgedetected = 0; | |
| 1244 | ✗ | for(int32_t i=0; i<4; i++) | |
| 1245 | { | ||
| 1246 | ✗ | int32_t tx=((i&2)<<2)+x; | |
| 1247 | ✗ | int32_t ty=((i&1)<<3)+y; | |
| 1248 | ✗ | int32_t tx2=((i&2)<<2)+cx; | |
| 1249 | ✗ | int32_t ty2=((i&1)<<3)+cy; | |
| 1250 | ✗ | for (int32_t m = layer; m <= 1; m++) | |
| 1251 | { | ||
| 1252 | ✗ | newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,tx2,ty2)]; | |
| 1253 | ✗ | if (get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1254 | { | ||
| 1255 | ✗ | if (cmb.type == cBRIDGE && !(cmb.walk&(1<<i))) | |
| 1256 | { | ||
| 1257 | ✗ | bridgedetected |= (1<<i); | |
| 1258 | ✗ | } | |
| 1259 | ✗ | } | |
| 1260 | else | ||
| 1261 | { | ||
| 1262 | ✗ | if (cmb.type == cBRIDGE && (cmb.walk&(0x10<<i))) | |
| 1263 | { | ||
| 1264 | ✗ | bridgedetected |= (1<<i); | |
| 1265 | ✗ | } | |
| 1266 | } | ||
| 1267 | ✗ | } | |
| 1268 | ✗ | if (bridgedetected & (1<<i)) | |
| 1269 | { | ||
| 1270 | ✗ | continue; | |
| 1271 | } | ||
| 1272 | ✗ | if(!(c.walk&(1<<i) && ((c.usrflags&cflag3) || (c.usrflags&cflag4))) && (layer==-1 || (get_qr(qr_WATER_ON_LAYER_1) && layer == 0) || (get_qr(qr_WATER_ON_LAYER_2) && layer == 1)) && combo_class_buf[c.type].water!=0 && get_qr(qr_DROWN)) | |
| 1273 | ✗ | rectfill(dest,tx,ty,tx+7,ty+7,vc(11)); | |
| 1274 | |||
| 1275 | |||
| 1276 | ✗ | if ((c.walk&(1<<(i+4))) && ((c.walk&(1<<i) && ((c.usrflags&cflag4)) && c.type == cWATER) || c.type == cSHALLOWWATER)) | |
| 1277 | { | ||
| 1278 | ✗ | for(int32_t k=0; k<8; k+=2) | |
| 1279 | ✗ | for(int32_t j=0; j<8; j+=2) | |
| 1280 | ✗ | if(((k+j)/2)%2) rectfill(dest,tx+k,ty+j,tx+k+1,ty+j+1,vc(11)); | |
| 1281 | ✗ | } | |
| 1282 | ✗ | if(c.walk&(1<<i) && !(combo_class_buf[c.type].water!=0 && ((c.usrflags&cflag3) || (c.usrflags&cflag4)))) | |
| 1283 | { | ||
| 1284 | ✗ | if(c.type==cLADDERHOOKSHOT && isstepable(MAPCOMBO3(map, screen, layer, cx,cy)) && ishookshottable(map, screen, cx,cy,i) && layer < 0) | |
| 1285 | { | ||
| 1286 | ✗ | for(int32_t k=0; k<8; k+=2) | |
| 1287 | ✗ | for(int32_t j=0; j<8; j+=2) | |
| 1288 | ✗ | rectfill(dest,tx+k,ty+j,tx+k+1,ty+j+1,vc(6+((k+j)/2)%2)); | |
| 1289 | ✗ | } | |
| 1290 | else | ||
| 1291 | { | ||
| 1292 | ✗ | int32_t color = COLOR_SOLID; | |
| 1293 | |||
| 1294 | ✗ | if(isstepable(MAPCOMBO3(map, screen, -1, cx,cy)) && (!get_qr(qr_NO_SOLID_SWIM) || combo_class_buf[combobuf[MAPCOMBO3(map, screen, -1, cx,cy)].type].water==0)) | |
| 1295 | ✗ | color=vc(6); | |
| 1296 | ✗ | else if((c.type==cHOOKSHOTONLY || c.type==cLADDERHOOKSHOT) && ishookshottable(map, screen, cx,cy,i)) | |
| 1297 | ✗ | color=vc(7); | |
| 1298 | |||
| 1299 | ✗ | rectfill(dest,tx,ty,tx+7,ty+7,color); | |
| 1300 | } | ||
| 1301 | ✗ | } | |
| 1302 | ✗ | } | |
| 1303 | |||
| 1304 | ✗ | bridgedetected = 0; | |
| 1305 | ✗ | for(int32_t i=0; i<4; i++) | |
| 1306 | { | ||
| 1307 | ✗ | int32_t tx2=((i&2)<<2)+cx; | |
| 1308 | ✗ | int32_t ty2=((i&1)<<3)+cy; | |
| 1309 | ✗ | for (int32_t m = 0; m <= 1; m++) | |
| 1310 | { | ||
| 1311 | ✗ | newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,tx2,ty2)]; | |
| 1312 | ✗ | if (get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1313 | { | ||
| 1314 | ✗ | if (cmb.type == cBRIDGE && !(cmb.walk&(1<<i))) | |
| 1315 | { | ||
| 1316 | ✗ | bridgedetected |= (1<<i); | |
| 1317 | ✗ | } | |
| 1318 | ✗ | } | |
| 1319 | else | ||
| 1320 | { | ||
| 1321 | ✗ | if (cmb.type == cBRIDGE && (cmb.walk&(0x10<<i))) | |
| 1322 | { | ||
| 1323 | ✗ | bridgedetected |= (1<<i); | |
| 1324 | ✗ | } | |
| 1325 | } | ||
| 1326 | ✗ | } | |
| 1327 | ✗ | } | |
| 1328 | |||
| 1329 | // Draw damage combos | ||
| 1330 | ✗ | newcombo const& c0 = combobuf[MAPCOMBO3(map, screen, -1,pos)]; | |
| 1331 | ✗ | newcombo const& c1 = combobuf[MAPCOMBO3(map, screen, 0,pos)]; | |
| 1332 | ✗ | newcombo const& c2 = combobuf[MAPCOMBO3(map, screen, 1,pos)]; | |
| 1333 | ✗ | bool dmg = combo_class_buf[c0.type].modify_hp_amount | |
| 1334 | ✗ | || combo_class_buf[c1.type].modify_hp_amount | |
| 1335 | ✗ | || combo_class_buf[c2.type].modify_hp_amount; | |
| 1336 | |||
| 1337 | ✗ | if (combo_class_buf[c2.type].modify_hp_amount) bridgedetected = 0; | |
| 1338 | |||
| 1339 | ✗ | if(dmg) | |
| 1340 | { | ||
| 1341 | ✗ | if (bridgedetected <= 0) | |
| 1342 | { | ||
| 1343 | ✗ | for(int32_t k=0; k<16; k+=2) | |
| 1344 | ✗ | for(int32_t j=0; j<16; j+=2) | |
| 1345 | ✗ | if(((k+j)/2)%2) | |
| 1346 | ✗ | rectfill(dest,x+k,y+j,x+k+1,y+j+1,vc(14)); | |
| 1347 | ✗ | } | |
| 1348 | else | ||
| 1349 | { | ||
| 1350 | ✗ | for(int32_t i=0; i<4; i++) | |
| 1351 | { | ||
| 1352 | ✗ | if (!(bridgedetected & (1<<i))) | |
| 1353 | { | ||
| 1354 | ✗ | int32_t tx=((i&2)<<2)+x; | |
| 1355 | ✗ | int32_t ty=((i&1)<<3)+y; | |
| 1356 | ✗ | for(int32_t k=0; k<8; k+=2) | |
| 1357 | ✗ | for(int32_t j=0; j<8; j+=2) | |
| 1358 | ✗ | if(((k+j)/2)%2) | |
| 1359 | ✗ | rectfill(dest,tx+k,ty+j,tx+k+1,ty+j+1,vc(14)); | |
| 1360 | ✗ | } | |
| 1361 | ✗ | } | |
| 1362 | } | ||
| 1363 | ✗ | } | |
| 1364 | |||
| 1365 | ✗ | if(c.type == cSLOPE) | |
| 1366 | { | ||
| 1367 | ✗ | slope_info s(c, x, y); | |
| 1368 | ✗ | s.draw(dest, 0, 0, COLOR_SLOPE); | |
| 1369 | ✗ | } | |
| 1370 | ✗ | auto fl0 = MAPFLAG3(map,screen,-1,pos); | |
| 1371 | ✗ | auto fl1 = MAPFLAG3(map,screen,0,pos); | |
| 1372 | ✗ | auto fl2 = MAPFLAG3(map,screen,1,pos); | |
| 1373 | ✗ | if(fl0 == mfSIDEVIEWLADDER || fl1 == mfSIDEVIEWLADDER || fl2 == mfSIDEVIEWLADDER | |
| 1374 | ✗ | || c0.flag == mfSIDEVIEWLADDER || c1.flag == mfSIDEVIEWLADDER || c2.flag == mfSIDEVIEWLADDER) | |
| 1375 | { | ||
| 1376 | ✗ | bool top = false; | |
| 1377 | ✗ | if(cy) | |
| 1378 | { | ||
| 1379 | ✗ | top = true; | |
| 1380 | ✗ | if(combobuf[MAPCOMBO3(map,screen,-1,cx,cy-16)].flag == mfSIDEVIEWLADDER | |
| 1381 | ✗ | || combobuf[MAPCOMBO3(map,screen,0,cx,cy-16)].flag == mfSIDEVIEWLADDER | |
| 1382 | ✗ | || combobuf[MAPCOMBO3(map,screen,1,cx,cy-16)].flag == mfSIDEVIEWLADDER | |
| 1383 | ✗ | || MAPFLAG3(map,screen,-1,cx,cy-16) == mfSIDEVIEWLADDER | |
| 1384 | ✗ | || MAPFLAG3(map,screen,0,cx,cy-16) == mfSIDEVIEWLADDER | |
| 1385 | ✗ | || MAPFLAG3(map,screen,1,cx,cy-16) == mfSIDEVIEWLADDER) | |
| 1386 | { | ||
| 1387 | ✗ | top = false; | |
| 1388 | ✗ | } | |
| 1389 | ✗ | } | |
| 1390 | ✗ | draw_ladder(dest,x,y,COLOR_LADDER,top); | |
| 1391 | ✗ | } | |
| 1392 | ✗ | else if(fl0 == mfSIDEVIEWPLATFORM || fl1 == mfSIDEVIEWPLATFORM || fl2 == mfSIDEVIEWPLATFORM | |
| 1393 | ✗ | || c0.flag == mfSIDEVIEWPLATFORM || c1.flag == mfSIDEVIEWPLATFORM || c2.flag == mfSIDEVIEWPLATFORM) | |
| 1394 | { | ||
| 1395 | ✗ | draw_platform(dest,x,y,COLOR_LADDER); | |
| 1396 | ✗ | } | |
| 1397 | ✗ | } | |
| 1398 | |||
| 1399 | ✗ | void put_walkflags(BITMAP *dest,int32_t x,int32_t y,word cmbdat,int32_t layer) | |
| 1400 | { | ||
| 1401 | ✗ | const newcombo& c = combobuf[cmbdat]; | |
| 1402 | |||
| 1403 | ✗ | if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) return; | |
| 1404 | |||
| 1405 | ✗ | for(int32_t i=0; i<4; i++) | |
| 1406 | { | ||
| 1407 | ✗ | int32_t tx=((i&2)<<2)+x; | |
| 1408 | ✗ | int32_t ty=((i&1)<<3)+y; | |
| 1409 | |||
| 1410 | ✗ | if(!(c.walk&(1<<i) && ((c.usrflags&cflag3) || (c.usrflags&cflag4))) && combo_class_buf[c.type].water!=0) | |
| 1411 | { | ||
| 1412 | ✗ | if ((layer==0 || (get_qr(qr_WATER_ON_LAYER_1) && layer == 1) || (get_qr(qr_WATER_ON_LAYER_2) && layer == 2)) && get_qr(qr_DROWN)) | |
| 1413 | { | ||
| 1414 | ✗ | rectfill(dest,tx,ty,tx+7,ty+7,vc(11)); | |
| 1415 | ✗ | } | |
| 1416 | else | ||
| 1417 | { | ||
| 1418 | ✗ | rectfill(dest,tx,ty,tx+7,ty+7,vc(11)); | |
| 1419 | } | ||
| 1420 | ✗ | } | |
| 1421 | |||
| 1422 | |||
| 1423 | ✗ | if ((c.walk&(1<<(i+4))) && ((c.walk&(1<<i) && ((c.usrflags&cflag4)) && c.type == cWATER) || c.type == cSHALLOWWATER)) | |
| 1424 | { | ||
| 1425 | ✗ | for(int32_t k=0; k<8; k+=2) | |
| 1426 | ✗ | for(int32_t j=0; j<8; j+=2) | |
| 1427 | ✗ | if(((k+j)/2)%2) rectfill(dest,tx+k,ty+j,tx+k+1,ty+j+1,vc(11)); | |
| 1428 | ✗ | } | |
| 1429 | ✗ | if(c.walk&(1<<i) && !(combo_class_buf[c.type].water!=0 && ((c.usrflags&cflag3) || (c.usrflags&cflag4)))) | |
| 1430 | { | ||
| 1431 | ✗ | if(c.type==cLADDERHOOKSHOT) | |
| 1432 | { | ||
| 1433 | ✗ | for(int32_t k=0; k<8; k+=2) | |
| 1434 | ✗ | for(int32_t j=0; j<8; j+=2) | |
| 1435 | ✗ | rectfill(dest,tx+k,ty+j,tx+k+1,ty+j+1,vc(6+((k+j)/2)%2)); | |
| 1436 | ✗ | } | |
| 1437 | else | ||
| 1438 | { | ||
| 1439 | ✗ | int32_t color = COLOR_SOLID; | |
| 1440 | |||
| 1441 | ✗ | if(c.type==cLADDERONLY) | |
| 1442 | ✗ | color=vc(6); | |
| 1443 | ✗ | else if(c.type==cHOOKSHOTONLY) | |
| 1444 | ✗ | color=vc(7); | |
| 1445 | |||
| 1446 | ✗ | rectfill(dest,tx,ty,tx+7,ty+7,color); | |
| 1447 | } | ||
| 1448 | ✗ | } | |
| 1449 | |||
| 1450 | // Draw damage combos | ||
| 1451 | ✗ | if(combo_class_buf[c.type].modify_hp_amount != 0) | |
| 1452 | { | ||
| 1453 | ✗ | for(int32_t k=0; k<8; k+=2) | |
| 1454 | ✗ | for(int32_t j=0; j<8; j+=2) | |
| 1455 | ✗ | if(((k+j)/2)%2) rectfill(dest,tx+k,ty+j,tx+k+1,ty+j+1,vc(4)); | |
| 1456 | ✗ | } | |
| 1457 | ✗ | } | |
| 1458 | |||
| 1459 | ✗ | if(c.type == cSLOPE) | |
| 1460 | { | ||
| 1461 | ✗ | slope_info s(c, 0, 0); | |
| 1462 | ✗ | zfix const& slope = s.slope(); | |
| 1463 | |||
| 1464 | ✗ | BITMAP* sub = create_bitmap_ex(8,16,16); | |
| 1465 | ✗ | clear_bitmap(sub); | |
| 1466 | ✗ | s.draw(sub, 0, 0, COLOR_SLOPE); | |
| 1467 | ✗ | masked_blit(sub, dest, 0, 0, x, y, 16, 16); | |
| 1468 | ✗ | destroy_bitmap(sub); | |
| 1469 | ✗ | } | |
| 1470 | ✗ | if(c.flag == mfSIDEVIEWLADDER) | |
| 1471 | { | ||
| 1472 | ✗ | draw_ladder(dest,x,y,COLOR_LADDER); | |
| 1473 | ✗ | } | |
| 1474 | ✗ | else if(c.flag == mfSIDEVIEWPLATFORM) | |
| 1475 | { | ||
| 1476 | ✗ | draw_platform(dest,x,y,COLOR_LADDER); | |
| 1477 | ✗ | } | |
| 1478 | ✗ | } | |
| 1479 | |||
| 1480 | ✗ | void put_flag(BITMAP* dest, int32_t x, int32_t y, int32_t flag) | |
| 1481 | { | ||
| 1482 | ✗ | rectfill(dest,x,y,x+15,y+15,vc(flag&15)); | |
| 1483 | ✗ | textprintf_ex(dest,get_zc_font(font_z3smallfont),x+1,y+1,vc(15-(flag&15)),-1,"%d",flag); | |
| 1484 | ✗ | } | |
| 1485 | ✗ | void put_flags(BITMAP *dest,int32_t x,int32_t y,word cmbdat,int32_t cset,int32_t flags,int32_t sflag) | |
| 1486 | { | ||
| 1487 | |||
| 1488 | ✗ | newcombo const& c = combobuf[cmbdat]; | |
| 1489 | |||
| 1490 | ✗ | if((flags&cFLAGS)&&(sflag||combobuf[cmbdat].flag)) | |
| 1491 | { | ||
| 1492 | // rectfill(dest,x,y,x+15,y+15,vc(cmbdat>>10+1)); | ||
| 1493 | // text_mode(-1); | ||
| 1494 | // textprintf_ex(dest,get_zc_font(font_sfont),x+1,y+1,(sflag)==0x7800?vc(0):vc(15),-1,"%d",sflag); | ||
| 1495 | ✗ | if(sflag) | |
| 1496 | { | ||
| 1497 | ✗ | rectfill(dest,x,y,x+15,y+15,vc(sflag&15)); | |
| 1498 | ✗ | textprintf_ex(dest,get_zc_font(font_z3smallfont),x+1,y+1,vc(15-(sflag&15)),-1,"%d",sflag); | |
| 1499 | ✗ | } | |
| 1500 | |||
| 1501 | ✗ | if(c.flag) | |
| 1502 | { | ||
| 1503 | ✗ | rectfill(dest,x,y+(sflag?8:0),x+15,y+15,vc((combobuf[cmbdat].flag)&15)); | |
| 1504 | ✗ | textprintf_ex(dest,get_zc_font(font_z3smallfont),x+1,y+9,vc(15-((combobuf[cmbdat].flag)&15)),-1,"%d",combobuf[cmbdat].flag); | |
| 1505 | ✗ | } | |
| 1506 | ✗ | } | |
| 1507 | |||
| 1508 | ✗ | if(flags&cCSET) | |
| 1509 | { | ||
| 1510 | ✗ | bool inv = (((cmbdat&0x7800)==0x7800)&&(flags&cFLAGS)); | |
| 1511 | // text_mode(inv?vc(15):vc(0)); | ||
| 1512 | ✗ | textprintf_ex(dest,get_zc_font(font_z3smallfont),x+9,y+9,inv?vc(0):vc(15),inv?vc(15):vc(0),"%d",cset); | |
| 1513 | ✗ | } | |
| 1514 | ✗ | else if(flags&cCTYPE) | |
| 1515 | { | ||
| 1516 | ✗ | bool inv = (((cmbdat&0x7800)==0x7800)&&(flags&cFLAGS)); | |
| 1517 | // text_mode(inv?vc(15):vc(0)); | ||
| 1518 | ✗ | textprintf_ex(dest,get_zc_font(font_z3smallfont),x+1,y+9,inv?vc(0):vc(15),inv?vc(15):vc(0),"%d",c.type); | |
| 1519 | ✗ | } | |
| 1520 | ✗ | } | |
| 1521 | |||
| 1522 | ✗ | void put_combo(BITMAP *dest,int32_t x,int32_t y,word cmbdat,int32_t cset,int32_t flags,int32_t sflag,int32_t scale) | |
| 1523 | { | ||
| 1524 | ✗ | bool repos = combotile_override_x < 0 && combotile_override_y < 0; | |
| 1525 | |||
| 1526 | ✗ | BITMAP* b = create_bitmap_ex(8,scale*16,scale*16); | |
| 1527 | ✗ | if(repos) | |
| 1528 | { | ||
| 1529 | ✗ | combotile_override_x = x+(8*(scale-1)); | |
| 1530 | ✗ | combotile_override_y = y+(8*(scale-1)); | |
| 1531 | ✗ | } | |
| 1532 | ✗ | put_combo(b,0,0,cmbdat,cset,flags,sflag); | |
| 1533 | ✗ | if(repos) combotile_override_x = combotile_override_y = -1; | |
| 1534 | ✗ | masked_stretch_blit(b,dest,0,0,16,16,x,y,16*scale,16*scale); | |
| 1535 | ✗ | destroy_bitmap(b); | |
| 1536 | ✗ | } | |
| 1537 | ✗ | void put_combo(BITMAP *dest,int32_t x,int32_t y,word cmbdat,int32_t cset,int32_t flags,int32_t sflag) | |
| 1538 | { | ||
| 1539 | ✗ | static newcombo nilcombo; | |
| 1540 | ✗ | nilcombo.tile = 0; | |
| 1541 | |||
| 1542 | ✗ | newcombo const& c = cmbdat < MAXCOMBOS ? combobuf[cmbdat] : nilcombo; | |
| 1543 | |||
| 1544 | ✗ | if(c.tile==0) | |
| 1545 | { | ||
| 1546 | ✗ | rectfill(dest,x,y,x+15,y+15,vc(0)); | |
| 1547 | ✗ | rectfill(dest,x+3,y+3,x+12,y+12,vc(4)); | |
| 1548 | ✗ | return; | |
| 1549 | } | ||
| 1550 | |||
| 1551 | ✗ | putcombo(dest,x,y,cmbdat,cset); | |
| 1552 | |||
| 1553 | ✗ | if((flags&cFLAGS)&&(sflag||combobuf[cmbdat].flag)) | |
| 1554 | { | ||
| 1555 | ✗ | if(sflag) | |
| 1556 | { | ||
| 1557 | ✗ | rectfill(dest,x,y,x+15,y+15,vc(sflag&15)); | |
| 1558 | ✗ | textprintf_ex(dest,get_zc_font(font_z3smallfont),x+1,y+1,vc(15-(sflag&15)),-1,"%d",sflag); | |
| 1559 | ✗ | } | |
| 1560 | |||
| 1561 | ✗ | if(combobuf[cmbdat].flag) | |
| 1562 | { | ||
| 1563 | ✗ | rectfill(dest,x,y+(sflag?8:0),x+15,y+15,vc((combobuf[cmbdat].flag)&15)); | |
| 1564 | ✗ | textprintf_ex(dest,get_zc_font(font_z3smallfont),x+1,y+1,vc(15-((combobuf[cmbdat].flag)&15)),-1,"%d",combobuf[cmbdat].flag); | |
| 1565 | ✗ | } | |
| 1566 | ✗ | } | |
| 1567 | |||
| 1568 | ✗ | if(flags&cWALK) | |
| 1569 | { | ||
| 1570 | ✗ | put_walkflags(dest,x,y,cmbdat,0); | |
| 1571 | ✗ | } | |
| 1572 | |||
| 1573 | ✗ | if(flags&cCSET) | |
| 1574 | { | ||
| 1575 | ✗ | bool inv = (((cmbdat&0x7800)==0x7800)&&(flags&cFLAGS)); | |
| 1576 | // text_mode(inv?vc(15):vc(0)); | ||
| 1577 | ✗ | textprintf_ex(dest,get_zc_font(font_z3smallfont),x+9,y+9,inv?vc(0):vc(15),inv?vc(15):vc(0),"%d",cset); | |
| 1578 | ✗ | } | |
| 1579 | ✗ | else if(flags&cCTYPE) | |
| 1580 | { | ||
| 1581 | ✗ | bool inv = (((cmbdat&0x7800)==0x7800)&&(flags&cFLAGS)); | |
| 1582 | // text_mode(inv?vc(15):vc(0)); | ||
| 1583 | ✗ | textprintf_ex(dest,get_zc_font(font_z3smallfont),x+1,y+9,inv?vc(0):vc(15),inv?vc(15):vc(0),"%d",c.type); | |
| 1584 | ✗ | } | |
| 1585 | ✗ | } | |
| 1586 | ✗ | void put_engraving(BITMAP* dest, int32_t x, int32_t y, int32_t slot, int32_t scale) | |
| 1587 | { | ||
| 1588 | ✗ | auto blitx = 1 + (slot % 16) * 17; | |
| 1589 | ✗ | auto blity = 1 + (slot / 16) * 17; | |
| 1590 | ✗ | masked_stretch_blit(asset_engravings_bmp, dest, blitx, blity, 16, 16, x, y, 16 * scale, 16 * scale); | |
| 1591 | ✗ | } | |
| 1592 | |||
| 1593 | |||
| 1594 | ✗ | void copy_mapscr(mapscr *dest, const mapscr *src) | |
| 1595 | { | ||
| 1596 | ✗ | if(!dest || !src) return; | |
| 1597 | ✗ | *dest = *src; | |
| 1598 | ✗ | } | |
| 1599 | |||
| 1600 | ✗ | void zmap::put_door(BITMAP *dest,int32_t pos,int32_t side,int32_t type,int32_t xofs,int32_t yofs,bool ignorepos, int32_t scr) | |
| 1601 | { | ||
| 1602 | ✗ | int32_t x=0,y=0; | |
| 1603 | ✗ | mapscr *doorscreen=(prv_mode?get_prvscr():screens+scr); | |
| 1604 | |||
| 1605 | ✗ | switch(side) | |
| 1606 | { | ||
| 1607 | case up: | ||
| 1608 | case down: | ||
| 1609 | ✗ | x=((pos&15)<<4)+xofs; | |
| 1610 | ✗ | y=(ignorepos?0:(pos&0xF0))+yofs; | |
| 1611 | ✗ | break; | |
| 1612 | |||
| 1613 | case left: | ||
| 1614 | case right: | ||
| 1615 | ✗ | x=(ignorepos?0:((pos&15)<<4))+xofs; | |
| 1616 | ✗ | y=(pos&0xF0)+yofs; | |
| 1617 | ✗ | break; | |
| 1618 | } | ||
| 1619 | |||
| 1620 | ✗ | switch(type) | |
| 1621 | { | ||
| 1622 | case dt_lock: | ||
| 1623 | case dt_shut: | ||
| 1624 | case dt_boss: | ||
| 1625 | case dt_bomb: | ||
| 1626 | ✗ | switch(side) | |
| 1627 | { | ||
| 1628 | case up: | ||
| 1629 | ✗ | put_combo(dest,x,y,DoorComboSets[doorscreen->door_combo_set].doorcombo_u[type][0], | |
| 1630 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_u[type][0],0,0); | |
| 1631 | ✗ | put_combo(dest,x+16,y,DoorComboSets[doorscreen->door_combo_set].doorcombo_u[type][1], | |
| 1632 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_u[type][1],0,0); | |
| 1633 | ✗ | put_combo(dest,x,y+16,DoorComboSets[doorscreen->door_combo_set].doorcombo_u[type][2], | |
| 1634 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_u[type][2],0,0); | |
| 1635 | ✗ | put_combo(dest,x+16,y+16,DoorComboSets[doorscreen->door_combo_set].doorcombo_u[type][3], | |
| 1636 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_u[type][3],0,0); | |
| 1637 | ✗ | break; | |
| 1638 | |||
| 1639 | case down: | ||
| 1640 | ✗ | put_combo(dest,x,y,DoorComboSets[doorscreen->door_combo_set].doorcombo_d[type][0], | |
| 1641 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_d[type][0],0,0); | |
| 1642 | ✗ | put_combo(dest,x+16,y,DoorComboSets[doorscreen->door_combo_set].doorcombo_d[type][1], | |
| 1643 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_d[type][1],0,0); | |
| 1644 | ✗ | put_combo(dest,x,y+16,DoorComboSets[doorscreen->door_combo_set].doorcombo_d[type][2], | |
| 1645 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_d[type][2],0,0); | |
| 1646 | ✗ | put_combo(dest,x+16,y+16,DoorComboSets[doorscreen->door_combo_set].doorcombo_d[type][3], | |
| 1647 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_d[type][3],0,0); | |
| 1648 | ✗ | break; | |
| 1649 | |||
| 1650 | case left: | ||
| 1651 | ✗ | put_combo(dest,x,y,DoorComboSets[doorscreen->door_combo_set].doorcombo_l[type][0], | |
| 1652 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_l[type][0],0,0); | |
| 1653 | ✗ | put_combo(dest,x,y+16,DoorComboSets[doorscreen->door_combo_set].doorcombo_l[type][2], | |
| 1654 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_l[type][2],0,0); | |
| 1655 | ✗ | put_combo(dest,x,y+32,DoorComboSets[doorscreen->door_combo_set].doorcombo_l[type][4], | |
| 1656 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_l[type][4],0,0); | |
| 1657 | |||
| 1658 | ✗ | if(x+16 >= dest->w) | |
| 1659 | ✗ | break; | |
| 1660 | |||
| 1661 | ✗ | put_combo(dest,x+16,y,DoorComboSets[doorscreen->door_combo_set].doorcombo_l[type][1], | |
| 1662 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_l[type][1],0,0); | |
| 1663 | ✗ | put_combo(dest,x+16,y+16,DoorComboSets[doorscreen->door_combo_set].doorcombo_l[type][3], | |
| 1664 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_l[type][3],0,0); | |
| 1665 | ✗ | put_combo(dest,x+16,y+32,DoorComboSets[doorscreen->door_combo_set].doorcombo_l[type][5], | |
| 1666 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_l[type][5],0,0); | |
| 1667 | ✗ | break; | |
| 1668 | |||
| 1669 | case right: | ||
| 1670 | |||
| 1671 | ✗ | put_combo(dest,x+16,y,DoorComboSets[doorscreen->door_combo_set].doorcombo_r[type][1], | |
| 1672 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_r[type][1],0,0); | |
| 1673 | ✗ | put_combo(dest,x+16,y+16,DoorComboSets[doorscreen->door_combo_set].doorcombo_r[type][3], | |
| 1674 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_r[type][3],0,0); | |
| 1675 | ✗ | put_combo(dest,x+16,y+32,DoorComboSets[doorscreen->door_combo_set].doorcombo_r[type][5], | |
| 1676 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_r[type][5],0,0); | |
| 1677 | |||
| 1678 | ✗ | if(x+16 <= 0) | |
| 1679 | ✗ | break; | |
| 1680 | |||
| 1681 | ✗ | put_combo(dest,x,y,DoorComboSets[doorscreen->door_combo_set].doorcombo_r[type][0], | |
| 1682 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_r[type][0],0,0); | |
| 1683 | ✗ | put_combo(dest,x,y+16,DoorComboSets[doorscreen->door_combo_set].doorcombo_r[type][2], | |
| 1684 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_r[type][2],0,0); | |
| 1685 | ✗ | put_combo(dest,x,y+32,DoorComboSets[doorscreen->door_combo_set].doorcombo_r[type][4], | |
| 1686 | ✗ | DoorComboSets[doorscreen->door_combo_set].doorcset_r[type][4],0,0); | |
| 1687 | ✗ | break; | |
| 1688 | } | ||
| 1689 | |||
| 1690 | ✗ | break; | |
| 1691 | |||
| 1692 | case dt_pass: | ||
| 1693 | case dt_wall: | ||
| 1694 | ✗ | case dt_walk: | |
| 1695 | default: | ||
| 1696 | ✗ | break; | |
| 1697 | } | ||
| 1698 | ✗ | } | |
| 1699 | |||
| 1700 | ✗ | void zmap::over_door(BITMAP *dest,int32_t pos,int32_t side,int32_t xofs,int32_t yofs,bool, int32_t scr) | |
| 1701 | { | ||
| 1702 | ✗ | int32_t x=((pos&15)<<4)+xofs; | |
| 1703 | ✗ | int32_t y=(pos&0xF0)+yofs; | |
| 1704 | ✗ | mapscr *doorscreen=(prv_mode?get_prvscr():screens+scr); | |
| 1705 | |||
| 1706 | |||
| 1707 | ✗ | switch(side) | |
| 1708 | { | ||
| 1709 | case up: | ||
| 1710 | ✗ | if(DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_u[0]!=0) | |
| 1711 | { | ||
| 1712 | ✗ | overcombo(dest,x,y, | |
| 1713 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_u[0], | |
| 1714 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcset_u[0]); | |
| 1715 | ✗ | } | |
| 1716 | |||
| 1717 | ✗ | if(DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_u[1]!=0) | |
| 1718 | { | ||
| 1719 | ✗ | overcombo(dest,x+16,y, | |
| 1720 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_u[1], | |
| 1721 | |||
| 1722 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcset_u[1]); | |
| 1723 | ✗ | } | |
| 1724 | |||
| 1725 | ✗ | break; | |
| 1726 | |||
| 1727 | case down: | ||
| 1728 | ✗ | if(DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_d[0]!=0) | |
| 1729 | { | ||
| 1730 | ✗ | overcombo(dest,x,y, | |
| 1731 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_d[0], | |
| 1732 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcset_d[0]); | |
| 1733 | ✗ | } | |
| 1734 | |||
| 1735 | ✗ | if(DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_d[1]!=0) | |
| 1736 | { | ||
| 1737 | ✗ | overcombo(dest,x+16,y, | |
| 1738 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_d[1], | |
| 1739 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcset_d[1]); | |
| 1740 | ✗ | } | |
| 1741 | |||
| 1742 | ✗ | break; | |
| 1743 | |||
| 1744 | case left: | ||
| 1745 | ✗ | if(DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_l[0]!=0) | |
| 1746 | { | ||
| 1747 | ✗ | overcombo(dest,x,y, | |
| 1748 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_l[0], | |
| 1749 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcset_l[0]); | |
| 1750 | ✗ | } | |
| 1751 | |||
| 1752 | ✗ | if(DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_l[1]!=0) | |
| 1753 | { | ||
| 1754 | ✗ | overcombo(dest,x,y+16, | |
| 1755 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_l[1], | |
| 1756 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcset_l[1]); | |
| 1757 | ✗ | } | |
| 1758 | |||
| 1759 | ✗ | if(DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_l[2]!=0) | |
| 1760 | { | ||
| 1761 | ✗ | overcombo(dest,x,y+32, | |
| 1762 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_l[2], | |
| 1763 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcset_l[2]); | |
| 1764 | ✗ | } | |
| 1765 | |||
| 1766 | ✗ | break; | |
| 1767 | |||
| 1768 | case right: | ||
| 1769 | ✗ | if(DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_r[0]!=0) | |
| 1770 | { | ||
| 1771 | ✗ | overcombo(dest,x,y, | |
| 1772 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_r[0], | |
| 1773 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcset_r[0]); | |
| 1774 | ✗ | } | |
| 1775 | |||
| 1776 | ✗ | if(DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_r[1]!=0) | |
| 1777 | { | ||
| 1778 | ✗ | overcombo(dest,x,y+16, | |
| 1779 | |||
| 1780 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_r[1], | |
| 1781 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcset_r[1]); | |
| 1782 | ✗ | } | |
| 1783 | |||
| 1784 | ✗ | if(DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_r[2]!=0) | |
| 1785 | { | ||
| 1786 | ✗ | overcombo(dest,x,y+32, | |
| 1787 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcombo_r[2], | |
| 1788 | ✗ | DoorComboSets[doorscreen->door_combo_set].bombdoorcset_r[2]); | |
| 1789 | ✗ | } | |
| 1790 | |||
| 1791 | ✗ | break; | |
| 1792 | } | ||
| 1793 | ✗ | } | |
| 1794 | |||
| 1795 | ✗ | bool zmap::misaligned(int32_t map, int32_t screen, int32_t i, int32_t dir) | |
| 1796 | { | ||
| 1797 | word cmbcheck1, cmbcheck2; | ||
| 1798 | ✗ | newcombo combocheck1, combocheck2; | |
| 1799 | ✗ | combocheck1 = combobuf[0]; | |
| 1800 | ✗ | combocheck2 = combobuf[0]; | |
| 1801 | ✗ | combocheck1.walk = 0; | |
| 1802 | ✗ | combocheck2.walk = 0; | |
| 1803 | |||
| 1804 | int32_t layermap, layerscreen; | ||
| 1805 | |||
| 1806 | ✗ | switch(dir) | |
| 1807 | { | ||
| 1808 | case up: | ||
| 1809 | { | ||
| 1810 | ✗ | if(i>15) //not top row of combos | |
| 1811 | { | ||
| 1812 | ✗ | return false; | |
| 1813 | } | ||
| 1814 | |||
| 1815 | ✗ | if(screen<16) //top row of screens | |
| 1816 | { | ||
| 1817 | ✗ | return false; | |
| 1818 | |||
| 1819 | } | ||
| 1820 | |||
| 1821 | //check main screen | ||
| 1822 | ✗ | cmbcheck1 = vbound(AbsoluteScr(map, screen)->data[i], 0, MAXCOMBOS-1); | |
| 1823 | ✗ | cmbcheck2 = vbound(AbsoluteScr(map, screen-16)->data[i+160], 0, MAXCOMBOS-1); | |
| 1824 | ✗ | if (combobuf[cmbcheck1].type != cBRIDGE || !get_qr(qr_OLD_BRIDGE_COMBOS)) combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 1825 | ✗ | if (combobuf[cmbcheck2].type != cBRIDGE || !get_qr(qr_OLD_BRIDGE_COMBOS)) combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 1826 | |||
| 1827 | //check layer 1 | ||
| 1828 | ✗ | layermap=AbsoluteScr(map, screen)->layermap[0]-1; | |
| 1829 | |||
| 1830 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 1831 | { | ||
| 1832 | ✗ | layerscreen=AbsoluteScr(map, screen)->layerscreen[0]; | |
| 1833 | ✗ | cmbcheck1 = AbsoluteScr(layermap, layerscreen)->data[i]; | |
| 1834 | ✗ | if (combobuf[cmbcheck1].type == cBRIDGE) | |
| 1835 | { | ||
| 1836 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1837 | { | ||
| 1838 | ✗ | int efflag = (combobuf[cmbcheck1].walk & 0xF0)>>4; | |
| 1839 | ✗ | int newsolid = (combobuf[cmbcheck1].walk & 0xF); | |
| 1840 | ✗ | combocheck1.walk = ((newsolid | combocheck1.walk) & (~efflag)) | (newsolid & efflag); | |
| 1841 | ✗ | } | |
| 1842 | ✗ | else combocheck1.walk&=combobuf[cmbcheck1].walk; | |
| 1843 | ✗ | } | |
| 1844 | ✗ | else combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 1845 | ✗ | } | |
| 1846 | |||
| 1847 | ✗ | layermap=AbsoluteScr(map, screen-16)->layermap[0]-1; | |
| 1848 | |||
| 1849 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 1850 | { | ||
| 1851 | ✗ | layerscreen=AbsoluteScr(map, screen-16)->layerscreen[0]; | |
| 1852 | ✗ | cmbcheck2 = AbsoluteScr(layermap, layerscreen)->data[i+160]; | |
| 1853 | ✗ | if (combobuf[cmbcheck2].type == cBRIDGE) | |
| 1854 | { | ||
| 1855 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1856 | { | ||
| 1857 | ✗ | int efflag = (combobuf[cmbcheck2].walk & 0xF0)>>4; | |
| 1858 | ✗ | int newsolid = (combobuf[cmbcheck2].walk & 0xF); | |
| 1859 | ✗ | combocheck2.walk = ((newsolid | combocheck2.walk) & (~efflag)) | (newsolid & efflag); | |
| 1860 | ✗ | } | |
| 1861 | ✗ | else combocheck2.walk&=combobuf[cmbcheck2].walk; | |
| 1862 | ✗ | } | |
| 1863 | ✗ | else combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 1864 | ✗ | } | |
| 1865 | |||
| 1866 | //check layer 2 | ||
| 1867 | ✗ | layermap=AbsoluteScr(map, screen)->layermap[1]-1; | |
| 1868 | |||
| 1869 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 1870 | { | ||
| 1871 | ✗ | layerscreen=AbsoluteScr(map, screen)->layerscreen[1]; | |
| 1872 | |||
| 1873 | ✗ | cmbcheck1 = AbsoluteScr(layermap, layerscreen)->data[i]; | |
| 1874 | ✗ | if (combobuf[cmbcheck2].type == cBRIDGE) | |
| 1875 | { | ||
| 1876 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1877 | { | ||
| 1878 | ✗ | int efflag = (combobuf[cmbcheck1].walk & 0xF0)>>4; | |
| 1879 | ✗ | int newsolid = (combobuf[cmbcheck1].walk & 0xF); | |
| 1880 | ✗ | combocheck1.walk = ((newsolid | combocheck1.walk) & (~efflag)) | (newsolid & efflag); | |
| 1881 | ✗ | } | |
| 1882 | ✗ | else combocheck1.walk&=combobuf[cmbcheck1].walk; | |
| 1883 | ✗ | } | |
| 1884 | ✗ | else combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 1885 | ✗ | } | |
| 1886 | |||
| 1887 | ✗ | layermap=AbsoluteScr(map, screen-16)->layermap[1]-1; | |
| 1888 | |||
| 1889 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 1890 | { | ||
| 1891 | ✗ | layerscreen=AbsoluteScr(map, screen-16)->layerscreen[1]; | |
| 1892 | ✗ | cmbcheck2 = AbsoluteScr(layermap, layerscreen)->data[i+160]; | |
| 1893 | ✗ | if (combobuf[cmbcheck2].type == cBRIDGE) | |
| 1894 | { | ||
| 1895 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1896 | { | ||
| 1897 | ✗ | int efflag = (combobuf[cmbcheck2].walk & 0xF0)>>4; | |
| 1898 | ✗ | int newsolid = (combobuf[cmbcheck2].walk & 0xF); | |
| 1899 | ✗ | combocheck2.walk = ((newsolid | combocheck2.walk) & (~efflag)) | (newsolid & efflag); | |
| 1900 | ✗ | } | |
| 1901 | ✗ | else combocheck2.walk&=combobuf[cmbcheck2].walk; | |
| 1902 | ✗ | } | |
| 1903 | ✗ | else combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 1904 | ✗ | } | |
| 1905 | |||
| 1906 | ✗ | if(((combocheck1.walk&5)*2)!=(combocheck2.walk&10)) | |
| 1907 | { | ||
| 1908 | ✗ | return true; | |
| 1909 | } | ||
| 1910 | |||
| 1911 | ✗ | break; | |
| 1912 | } | ||
| 1913 | case down: | ||
| 1914 | { | ||
| 1915 | ✗ | if(i<160) //not bottom row of combos | |
| 1916 | { | ||
| 1917 | ✗ | return false; | |
| 1918 | } | ||
| 1919 | |||
| 1920 | ✗ | if(screen>111) //bottom row of screens | |
| 1921 | { | ||
| 1922 | ✗ | return false; | |
| 1923 | } | ||
| 1924 | |||
| 1925 | //check main screen | ||
| 1926 | ✗ | cmbcheck1 = vbound(AbsoluteScr(map, screen)->data[i], 0, MAXCOMBOS-1); | |
| 1927 | ✗ | cmbcheck2 = vbound(AbsoluteScr(map, screen+16)->data[i-160], 0, MAXCOMBOS-1); | |
| 1928 | ✗ | if (combobuf[cmbcheck1].type != cBRIDGE || !get_qr(qr_OLD_BRIDGE_COMBOS)) combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 1929 | ✗ | if (combobuf[cmbcheck2].type != cBRIDGE || !get_qr(qr_OLD_BRIDGE_COMBOS)) combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 1930 | |||
| 1931 | |||
| 1932 | //check layer 1 | ||
| 1933 | ✗ | layermap=AbsoluteScr(map, screen)->layermap[0]-1; | |
| 1934 | |||
| 1935 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 1936 | { | ||
| 1937 | ✗ | layerscreen=AbsoluteScr(map, screen)->layerscreen[0]; | |
| 1938 | ✗ | cmbcheck1 = AbsoluteScr(layermap, layerscreen)->data[i]; | |
| 1939 | ✗ | if (combobuf[cmbcheck1].type == cBRIDGE) | |
| 1940 | { | ||
| 1941 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1942 | { | ||
| 1943 | ✗ | int efflag = (combobuf[cmbcheck1].walk & 0xF0)>>4; | |
| 1944 | ✗ | int newsolid = (combobuf[cmbcheck1].walk & 0xF); | |
| 1945 | ✗ | combocheck1.walk = ((newsolid | combocheck1.walk) & (~efflag)) | (newsolid & efflag); | |
| 1946 | ✗ | } | |
| 1947 | ✗ | else combocheck1.walk&=combobuf[cmbcheck1].walk; | |
| 1948 | ✗ | } | |
| 1949 | ✗ | else combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 1950 | ✗ | } | |
| 1951 | |||
| 1952 | ✗ | layermap=AbsoluteScr(map, screen+16)->layermap[0]-1; | |
| 1953 | |||
| 1954 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 1955 | { | ||
| 1956 | ✗ | layerscreen=AbsoluteScr(map, screen+16)->layerscreen[0]; | |
| 1957 | ✗ | cmbcheck2 = AbsoluteScr(layermap, layerscreen)->data[i-160]; | |
| 1958 | ✗ | if (combobuf[cmbcheck2].type == cBRIDGE) | |
| 1959 | { | ||
| 1960 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1961 | { | ||
| 1962 | ✗ | int efflag = (combobuf[cmbcheck2].walk & 0xF0)>>4; | |
| 1963 | ✗ | int newsolid = (combobuf[cmbcheck2].walk & 0xF); | |
| 1964 | ✗ | combocheck2.walk = ((newsolid | combocheck2.walk) & (~efflag)) | (newsolid & efflag); | |
| 1965 | ✗ | } | |
| 1966 | ✗ | else combocheck2.walk&=combobuf[cmbcheck2].walk; | |
| 1967 | ✗ | } | |
| 1968 | ✗ | else combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 1969 | ✗ | } | |
| 1970 | |||
| 1971 | //check layer 2 | ||
| 1972 | ✗ | layermap=AbsoluteScr(map, screen)->layermap[1]-1; | |
| 1973 | |||
| 1974 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 1975 | { | ||
| 1976 | ✗ | layerscreen=AbsoluteScr(map, screen)->layerscreen[1]; | |
| 1977 | ✗ | cmbcheck1 = AbsoluteScr(layermap, layerscreen)->data[i]; | |
| 1978 | ✗ | if (combobuf[cmbcheck1].type == cBRIDGE) | |
| 1979 | { | ||
| 1980 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 1981 | { | ||
| 1982 | ✗ | int efflag = (combobuf[cmbcheck1].walk & 0xF0)>>4; | |
| 1983 | ✗ | int newsolid = (combobuf[cmbcheck1].walk & 0xF); | |
| 1984 | ✗ | combocheck1.walk = ((newsolid | combocheck1.walk) & (~efflag)) | (newsolid & efflag); | |
| 1985 | ✗ | } | |
| 1986 | ✗ | else combocheck1.walk&=combobuf[cmbcheck1].walk; | |
| 1987 | ✗ | } | |
| 1988 | ✗ | else combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 1989 | ✗ | } | |
| 1990 | |||
| 1991 | ✗ | layermap=AbsoluteScr(map, screen+16)->layermap[1]-1; | |
| 1992 | |||
| 1993 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 1994 | { | ||
| 1995 | ✗ | layerscreen=AbsoluteScr(map, screen+16)->layerscreen[1]; | |
| 1996 | ✗ | cmbcheck2 = AbsoluteScr(layermap, layerscreen)->data[i-160]; | |
| 1997 | ✗ | if (combobuf[cmbcheck2].type == cBRIDGE) | |
| 1998 | { | ||
| 1999 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 2000 | { | ||
| 2001 | ✗ | int efflag = (combobuf[cmbcheck2].walk & 0xF0)>>4; | |
| 2002 | ✗ | int newsolid = (combobuf[cmbcheck2].walk & 0xF); | |
| 2003 | ✗ | combocheck2.walk = ((newsolid | combocheck2.walk) & (~efflag)) | (newsolid & efflag); | |
| 2004 | ✗ | } | |
| 2005 | ✗ | else combocheck2.walk&=combobuf[cmbcheck2].walk; | |
| 2006 | ✗ | } | |
| 2007 | ✗ | else combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 2008 | ✗ | } | |
| 2009 | |||
| 2010 | ✗ | if((combocheck1.walk&10)!=((combocheck2.walk&5)*2)) | |
| 2011 | { | ||
| 2012 | ✗ | return true; | |
| 2013 | } | ||
| 2014 | |||
| 2015 | ✗ | break; | |
| 2016 | } | ||
| 2017 | case left: | ||
| 2018 | { | ||
| 2019 | ✗ | if((i&0xF)!=0) //not left column of combos | |
| 2020 | { | ||
| 2021 | ✗ | return false; | |
| 2022 | } | ||
| 2023 | |||
| 2024 | ✗ | if((screen&0xF)==0) //left column of screens | |
| 2025 | { | ||
| 2026 | ✗ | return false; | |
| 2027 | } | ||
| 2028 | |||
| 2029 | //check main screen | ||
| 2030 | ✗ | cmbcheck1 = AbsoluteScr(map, screen)->data[i]; | |
| 2031 | ✗ | cmbcheck2 = AbsoluteScr(map, screen-1)->data[i+15]; | |
| 2032 | ✗ | if (combobuf[cmbcheck1].type != cBRIDGE || !get_qr(qr_OLD_BRIDGE_COMBOS)) combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 2033 | ✗ | if (combobuf[cmbcheck2].type != cBRIDGE || !get_qr(qr_OLD_BRIDGE_COMBOS)) combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 2034 | |||
| 2035 | //check layer 1 | ||
| 2036 | ✗ | layermap=AbsoluteScr(map, screen)->layermap[0]-1; | |
| 2037 | |||
| 2038 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 2039 | { | ||
| 2040 | ✗ | layerscreen=AbsoluteScr(map, screen)->layerscreen[0]; | |
| 2041 | ✗ | cmbcheck1 = AbsoluteScr(layermap, layerscreen)->data[i]; | |
| 2042 | ✗ | if (combobuf[cmbcheck1].type == cBRIDGE) | |
| 2043 | { | ||
| 2044 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 2045 | { | ||
| 2046 | ✗ | int efflag = (combobuf[cmbcheck1].walk & 0xF0)>>4; | |
| 2047 | ✗ | int newsolid = (combobuf[cmbcheck1].walk & 0xF); | |
| 2048 | ✗ | combocheck1.walk = ((newsolid | combocheck1.walk) & (~efflag)) | (newsolid & efflag); | |
| 2049 | ✗ | } | |
| 2050 | ✗ | else combocheck1.walk&=combobuf[cmbcheck1].walk; | |
| 2051 | ✗ | } | |
| 2052 | ✗ | else combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 2053 | ✗ | } | |
| 2054 | |||
| 2055 | ✗ | layermap=AbsoluteScr(map, screen-1)->layermap[0]-1; | |
| 2056 | |||
| 2057 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 2058 | { | ||
| 2059 | ✗ | layerscreen=AbsoluteScr(map, screen-1)->layerscreen[0]; | |
| 2060 | ✗ | cmbcheck2 = AbsoluteScr(layermap, layerscreen)->data[i+15]; | |
| 2061 | ✗ | if (combobuf[cmbcheck2].type == cBRIDGE) | |
| 2062 | { | ||
| 2063 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 2064 | { | ||
| 2065 | ✗ | int efflag = (combobuf[cmbcheck2].walk & 0xF0)>>4; | |
| 2066 | ✗ | int newsolid = (combobuf[cmbcheck2].walk & 0xF); | |
| 2067 | ✗ | combocheck2.walk = ((newsolid | combocheck2.walk) & (~efflag)) | (newsolid & efflag); | |
| 2068 | ✗ | } | |
| 2069 | ✗ | else combocheck2.walk&=combobuf[cmbcheck2].walk; | |
| 2070 | ✗ | } | |
| 2071 | ✗ | else combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 2072 | ✗ | } | |
| 2073 | |||
| 2074 | //check layer 2 | ||
| 2075 | ✗ | layermap=AbsoluteScr(map, screen)->layermap[1]-1; | |
| 2076 | |||
| 2077 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 2078 | { | ||
| 2079 | ✗ | layerscreen=AbsoluteScr(map, screen)->layerscreen[1]; | |
| 2080 | ✗ | cmbcheck1 = AbsoluteScr(layermap, layerscreen)->data[i]; | |
| 2081 | ✗ | if (combobuf[cmbcheck1].type == cBRIDGE) | |
| 2082 | { | ||
| 2083 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 2084 | { | ||
| 2085 | ✗ | int efflag = (combobuf[cmbcheck1].walk & 0xF0)>>4; | |
| 2086 | ✗ | int newsolid = (combobuf[cmbcheck1].walk & 0xF); | |
| 2087 | ✗ | combocheck1.walk = ((newsolid | combocheck1.walk) & (~efflag)) | (newsolid & efflag); | |
| 2088 | ✗ | } | |
| 2089 | ✗ | else combocheck1.walk&=combobuf[cmbcheck1].walk; | |
| 2090 | ✗ | } | |
| 2091 | ✗ | else combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 2092 | ✗ | } | |
| 2093 | |||
| 2094 | ✗ | layermap=AbsoluteScr(map, screen-1)->layermap[1]-1; | |
| 2095 | |||
| 2096 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 2097 | { | ||
| 2098 | ✗ | layerscreen=AbsoluteScr(map, screen-1)->layerscreen[1]; | |
| 2099 | ✗ | cmbcheck2 = AbsoluteScr(layermap, layerscreen)->data[i+15]; | |
| 2100 | ✗ | if (combobuf[cmbcheck2].type == cBRIDGE) | |
| 2101 | { | ||
| 2102 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 2103 | { | ||
| 2104 | ✗ | int efflag = (combobuf[cmbcheck2].walk & 0xF0)>>4; | |
| 2105 | ✗ | int newsolid = (combobuf[cmbcheck2].walk & 0xF); | |
| 2106 | ✗ | combocheck2.walk = ((newsolid | combocheck2.walk) & (~efflag)) | (newsolid & efflag); | |
| 2107 | ✗ | } | |
| 2108 | ✗ | else combocheck2.walk&=combobuf[cmbcheck2].walk; | |
| 2109 | ✗ | } | |
| 2110 | ✗ | else combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 2111 | ✗ | } | |
| 2112 | |||
| 2113 | ✗ | if(((combocheck1.walk&3)*4)!=(combocheck2.walk&12)) | |
| 2114 | { | ||
| 2115 | ✗ | return true; | |
| 2116 | } | ||
| 2117 | |||
| 2118 | ✗ | break; | |
| 2119 | } | ||
| 2120 | case right: | ||
| 2121 | { | ||
| 2122 | ✗ | if((i&0xF)!=15) //not right column of combos | |
| 2123 | { | ||
| 2124 | ✗ | return false; | |
| 2125 | } | ||
| 2126 | |||
| 2127 | ✗ | if((screen&0xF)==15) //right column of screens | |
| 2128 | { | ||
| 2129 | ✗ | return false; | |
| 2130 | } | ||
| 2131 | |||
| 2132 | //check main screen | ||
| 2133 | ✗ | cmbcheck1 = AbsoluteScr(map, screen)->data[i]; | |
| 2134 | ✗ | cmbcheck2 = AbsoluteScr(map, screen+1)->data[i-15]; | |
| 2135 | ✗ | if (combobuf[cmbcheck1].type != cBRIDGE || !get_qr(qr_OLD_BRIDGE_COMBOS)) combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 2136 | ✗ | if (combobuf[cmbcheck2].type != cBRIDGE || !get_qr(qr_OLD_BRIDGE_COMBOS)) combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 2137 | |||
| 2138 | //check layer 1 | ||
| 2139 | ✗ | layermap=AbsoluteScr(map, screen)->layermap[0]-1; | |
| 2140 | |||
| 2141 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 2142 | { | ||
| 2143 | ✗ | layerscreen=AbsoluteScr(map, screen)->layerscreen[0]; | |
| 2144 | ✗ | cmbcheck1 = AbsoluteScr(layermap, layerscreen)->data[i]; | |
| 2145 | ✗ | if (combobuf[cmbcheck1].type == cBRIDGE) | |
| 2146 | { | ||
| 2147 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 2148 | { | ||
| 2149 | ✗ | int efflag = (combobuf[cmbcheck1].walk & 0xF0)>>4; | |
| 2150 | ✗ | int newsolid = (combobuf[cmbcheck1].walk & 0xF); | |
| 2151 | ✗ | combocheck1.walk = ((newsolid | combocheck1.walk) & (~efflag)) | (newsolid & efflag); | |
| 2152 | ✗ | } | |
| 2153 | ✗ | else combocheck1.walk&=combobuf[cmbcheck1].walk; | |
| 2154 | ✗ | } | |
| 2155 | ✗ | else combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 2156 | ✗ | } | |
| 2157 | |||
| 2158 | ✗ | layermap=AbsoluteScr(map, screen+1)->layermap[0]-1; | |
| 2159 | |||
| 2160 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 2161 | { | ||
| 2162 | ✗ | layerscreen=AbsoluteScr(map, screen+1)->layerscreen[0]; | |
| 2163 | ✗ | cmbcheck2 = AbsoluteScr(layermap, layerscreen)->data[i-15]; | |
| 2164 | ✗ | if (combobuf[cmbcheck2].type == cBRIDGE) | |
| 2165 | { | ||
| 2166 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 2167 | { | ||
| 2168 | ✗ | int efflag = (combobuf[cmbcheck2].walk & 0xF0)>>4; | |
| 2169 | ✗ | int newsolid = (combobuf[cmbcheck2].walk & 0xF); | |
| 2170 | ✗ | combocheck2.walk = ((newsolid | combocheck2.walk) & (~efflag)) | (newsolid & efflag); | |
| 2171 | ✗ | } | |
| 2172 | ✗ | else combocheck2.walk&=combobuf[cmbcheck2].walk; | |
| 2173 | ✗ | } | |
| 2174 | ✗ | else combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 2175 | ✗ | } | |
| 2176 | |||
| 2177 | //check layer 2 | ||
| 2178 | ✗ | layermap=AbsoluteScr(map, screen)->layermap[1]-1; | |
| 2179 | |||
| 2180 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 2181 | { | ||
| 2182 | ✗ | layerscreen=AbsoluteScr(map, screen)->layerscreen[1]; | |
| 2183 | ✗ | cmbcheck1 = AbsoluteScr(layermap, layerscreen)->data[i]; | |
| 2184 | ✗ | if (combobuf[cmbcheck1].type == cBRIDGE) | |
| 2185 | { | ||
| 2186 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 2187 | { | ||
| 2188 | ✗ | int efflag = (combobuf[cmbcheck1].walk & 0xF0)>>4; | |
| 2189 | ✗ | int newsolid = (combobuf[cmbcheck1].walk & 0xF); | |
| 2190 | ✗ | combocheck1.walk = ((newsolid | combocheck1.walk) & (~efflag)) | (newsolid & efflag); | |
| 2191 | ✗ | } | |
| 2192 | ✗ | else combocheck1.walk&=combobuf[cmbcheck1].walk; | |
| 2193 | ✗ | } | |
| 2194 | ✗ | else combocheck1.walk|=combobuf[cmbcheck1].walk; | |
| 2195 | ✗ | } | |
| 2196 | |||
| 2197 | ✗ | layermap=AbsoluteScr(map, screen+1)->layermap[1]-1; | |
| 2198 | |||
| 2199 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 2200 | { | ||
| 2201 | ✗ | layerscreen=AbsoluteScr(map, screen+1)->layerscreen[1]; | |
| 2202 | |||
| 2203 | ✗ | cmbcheck2 = AbsoluteScr(layermap, layerscreen)->data[i-15]; | |
| 2204 | ✗ | if (combobuf[cmbcheck2].type == cBRIDGE) | |
| 2205 | { | ||
| 2206 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 2207 | { | ||
| 2208 | ✗ | int efflag = (combobuf[cmbcheck2].walk & 0xF0)>>4; | |
| 2209 | ✗ | int newsolid = (combobuf[cmbcheck2].walk & 0xF); | |
| 2210 | ✗ | combocheck2.walk = ((newsolid | combocheck2.walk) & (~efflag)) | (newsolid & efflag); | |
| 2211 | ✗ | } | |
| 2212 | ✗ | else combocheck2.walk&=combobuf[cmbcheck2].walk; | |
| 2213 | ✗ | } | |
| 2214 | ✗ | else combocheck2.walk|=combobuf[cmbcheck2].walk; | |
| 2215 | ✗ | } | |
| 2216 | |||
| 2217 | ✗ | if((combocheck1.walk&12)!=((combocheck2.walk&3)*4)) | |
| 2218 | { | ||
| 2219 | ✗ | return true; | |
| 2220 | } | ||
| 2221 | |||
| 2222 | ✗ | break; | |
| 2223 | } | ||
| 2224 | } | ||
| 2225 | |||
| 2226 | ✗ | return false; | |
| 2227 | ✗ | } | |
| 2228 | |||
| 2229 | ✗ | void zmap::check_alignments(BITMAP* dest,int32_t x,int32_t y,int32_t scr) | |
| 2230 | { | ||
| 2231 | int32_t checkcombo; | ||
| 2232 | |||
| 2233 | ✗ | if(alignment_arrow_timer>31) | |
| 2234 | { | ||
| 2235 | ✗ | if(scr<0) | |
| 2236 | { | ||
| 2237 | ✗ | scr=cursor.screen; | |
| 2238 | ✗ | } | |
| 2239 | |||
| 2240 | ✗ | if((scr<128)) //do the misalignment arrows | |
| 2241 | { | ||
| 2242 | ✗ | for(checkcombo=1; checkcombo<15; checkcombo++) //check the top row (except the corners) | |
| 2243 | { | ||
| 2244 | ✗ | if(misaligned(cursor.map, scr, checkcombo, up)) | |
| 2245 | { | ||
| 2246 | ✗ | masked_blit(arrow_bmp[0],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2247 | ✗ | } | |
| 2248 | ✗ | } | |
| 2249 | |||
| 2250 | ✗ | for(checkcombo=161; checkcombo<175; checkcombo++) //check the top row (except the corners) | |
| 2251 | { | ||
| 2252 | ✗ | if(misaligned(cursor.map, scr, checkcombo, down)) | |
| 2253 | { | ||
| 2254 | ✗ | masked_blit(arrow_bmp[1],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2255 | ✗ | } | |
| 2256 | ✗ | } | |
| 2257 | |||
| 2258 | ✗ | for(checkcombo=16; checkcombo<160; checkcombo+=16) //check the left side (except the corners) | |
| 2259 | { | ||
| 2260 | ✗ | if(misaligned(cursor.map, scr, checkcombo, left)) | |
| 2261 | { | ||
| 2262 | ✗ | masked_blit(arrow_bmp[2],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2263 | ✗ | } | |
| 2264 | ✗ | } | |
| 2265 | |||
| 2266 | ✗ | for(checkcombo=31; checkcombo<175; checkcombo+=16) //check the right side (except the corners) | |
| 2267 | { | ||
| 2268 | ✗ | if(misaligned(cursor.map, scr, checkcombo, right)) | |
| 2269 | { | ||
| 2270 | ✗ | masked_blit(arrow_bmp[3],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2271 | ✗ | } | |
| 2272 | ✗ | } | |
| 2273 | |||
| 2274 | int32_t tempalign; | ||
| 2275 | |||
| 2276 | //check top left corner | ||
| 2277 | ✗ | checkcombo=0; | |
| 2278 | ✗ | tempalign=0; | |
| 2279 | ✗ | tempalign+=(misaligned(cursor.map, scr, checkcombo, up))?1:0; | |
| 2280 | ✗ | tempalign+=(misaligned(cursor.map, scr, checkcombo, left))?2:0; | |
| 2281 | |||
| 2282 | ✗ | switch(tempalign) | |
| 2283 | { | ||
| 2284 | case 0: | ||
| 2285 | ✗ | break; | |
| 2286 | |||
| 2287 | case 1: //up | ||
| 2288 | ✗ | masked_blit(arrow_bmp[0],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2289 | ✗ | break; | |
| 2290 | |||
| 2291 | case 2: //left | ||
| 2292 | ✗ | masked_blit(arrow_bmp[2],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2293 | ✗ | break; | |
| 2294 | |||
| 2295 | case 3: //up-left | ||
| 2296 | ✗ | masked_blit(arrow_bmp[4],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2297 | ✗ | break; | |
| 2298 | } | ||
| 2299 | |||
| 2300 | //check top right corner | ||
| 2301 | ✗ | checkcombo=15; | |
| 2302 | ✗ | tempalign=0; | |
| 2303 | ✗ | tempalign+=(misaligned(cursor.map, scr, checkcombo, up))?1:0; | |
| 2304 | ✗ | tempalign+=(misaligned(cursor.map, scr, checkcombo, right))?2:0; | |
| 2305 | |||
| 2306 | ✗ | switch(tempalign) | |
| 2307 | { | ||
| 2308 | case 0: | ||
| 2309 | ✗ | break; | |
| 2310 | |||
| 2311 | case 1: //up | ||
| 2312 | ✗ | masked_blit(arrow_bmp[0],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2313 | ✗ | break; | |
| 2314 | |||
| 2315 | case 2: //right | ||
| 2316 | ✗ | masked_blit(arrow_bmp[3],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2317 | ✗ | break; | |
| 2318 | |||
| 2319 | case 3: //up-right | ||
| 2320 | ✗ | masked_blit(arrow_bmp[5],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2321 | ✗ | break; | |
| 2322 | } | ||
| 2323 | |||
| 2324 | //check bottom left corner | ||
| 2325 | ✗ | checkcombo=160; | |
| 2326 | ✗ | tempalign=0; | |
| 2327 | ✗ | tempalign+=(misaligned(cursor.map, scr, checkcombo, down))?1:0; | |
| 2328 | ✗ | tempalign+=(misaligned(cursor.map, scr, checkcombo, left))?2:0; | |
| 2329 | |||
| 2330 | ✗ | switch(tempalign) | |
| 2331 | { | ||
| 2332 | case 0: | ||
| 2333 | ✗ | break; | |
| 2334 | |||
| 2335 | case 1: //down | ||
| 2336 | ✗ | masked_blit(arrow_bmp[1],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2337 | ✗ | break; | |
| 2338 | |||
| 2339 | case 2: //left | ||
| 2340 | ✗ | masked_blit(arrow_bmp[2],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2341 | ✗ | break; | |
| 2342 | |||
| 2343 | case 3: //down-left | ||
| 2344 | ✗ | masked_blit(arrow_bmp[6],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2345 | ✗ | break; | |
| 2346 | } | ||
| 2347 | |||
| 2348 | //check bottom right corner | ||
| 2349 | |||
| 2350 | ✗ | checkcombo=175; | |
| 2351 | ✗ | tempalign=0; | |
| 2352 | ✗ | tempalign+=(misaligned(cursor.map, scr, checkcombo, down))?1:0; | |
| 2353 | ✗ | tempalign+=(misaligned(cursor.map, scr, checkcombo, right))?2:0; | |
| 2354 | |||
| 2355 | ✗ | switch(tempalign) | |
| 2356 | { | ||
| 2357 | case 0: | ||
| 2358 | ✗ | break; | |
| 2359 | |||
| 2360 | case 1: //down | ||
| 2361 | ✗ | masked_blit(arrow_bmp[1],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2362 | ✗ | break; | |
| 2363 | |||
| 2364 | case 2: //right | ||
| 2365 | ✗ | masked_blit(arrow_bmp[3],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2366 | ✗ | break; | |
| 2367 | |||
| 2368 | case 3: //down-right | ||
| 2369 | ✗ | masked_blit(arrow_bmp[7],dest,0,0,((checkcombo&15)<<4)+x,(checkcombo&0xF0)+y,16,16); | |
| 2370 | ✗ | break; | |
| 2371 | } | ||
| 2372 | ✗ | } | |
| 2373 | ✗ | } | |
| 2374 | ✗ | } | |
| 2375 | |||
| 2376 | ✗ | int32_t zmap::MAPCOMBO3(int32_t map, int32_t screen, int32_t layer, int32_t x,int32_t y) | |
| 2377 | { | ||
| 2378 | ✗ | return MAPCOMBO3(map, screen, layer, COMBOPOS(x,y)); | |
| 2379 | } | ||
| 2380 | |||
| 2381 | ✗ | int32_t zmap::MAPCOMBO3(int32_t map, int32_t screen, int32_t layer, int32_t pos) | |
| 2382 | { | ||
| 2383 | ✗ | if (map < 0 || screen < 0) return 0; | |
| 2384 | |||
| 2385 | ✗ | if(pos>175 || pos < 0) | |
| 2386 | ✗ | return 0; | |
| 2387 | |||
| 2388 | ✗ | mapscr const* m = &TheMaps[(map*MAPSCRS)+screen]; | |
| 2389 | |||
| 2390 | ✗ | if (!m->is_valid()) return 0; | |
| 2391 | |||
| 2392 | ✗ | int32_t mapid = (layer < 0 ? -1 : ((m->layermap[layer] - 1) * MAPSCRS + m->layerscreen[layer])); | |
| 2393 | |||
| 2394 | ✗ | if (layer >= 0 && (mapid < 0 || mapid > MAXMAPS*MAPSCRS)) return 0; | |
| 2395 | |||
| 2396 | ✗ | mapscr const* scr = ((mapid < 0 || mapid > MAXMAPS*MAPSCRS) ? m : &TheMaps[mapid]); | |
| 2397 | |||
| 2398 | ✗ | if (!scr->is_valid()) return 0; | |
| 2399 | |||
| 2400 | ✗ | return scr->data[pos]; // entire combo code | |
| 2401 | ✗ | } | |
| 2402 | |||
| 2403 | // Takes array index layer num., not actual layer num. | ||
| 2404 | ✗ | int32_t zmap::MAPCOMBO2(int32_t lyr,int32_t x,int32_t y, int32_t map, int32_t scr) | |
| 2405 | { | ||
| 2406 | ✗ | if(lyr<=-1) return MAPCOMBO(x,y,map,scr); | |
| 2407 | |||
| 2408 | ✗ | if(map<0) | |
| 2409 | ✗ | map=cursor.map; | |
| 2410 | |||
| 2411 | ✗ | if(scr<0) | |
| 2412 | ✗ | scr=cursor.screen; | |
| 2413 | |||
| 2414 | mapscr *screen1; | ||
| 2415 | |||
| 2416 | ✗ | if(prv_mode) | |
| 2417 | { | ||
| 2418 | ✗ | screen1=get_prvscr(); | |
| 2419 | ✗ | } | |
| 2420 | else | ||
| 2421 | { | ||
| 2422 | ✗ | screen1=AbsoluteScr(cursor.map,cursor.screen); | |
| 2423 | } | ||
| 2424 | |||
| 2425 | int32_t layermap; | ||
| 2426 | ✗ | layermap=screen1->layermap[lyr]-1; | |
| 2427 | |||
| 2428 | ✗ | if(layermap<0 || layermap >= map_count) return 0; | |
| 2429 | |||
| 2430 | mapscr *layer; | ||
| 2431 | |||
| 2432 | ✗ | if(prv_mode) | |
| 2433 | ✗ | layer = &prvlayers[lyr]; | |
| 2434 | else | ||
| 2435 | ✗ | layer = AbsoluteScr(layermap,screen1->layerscreen[lyr]); | |
| 2436 | |||
| 2437 | ✗ | int32_t pos = COMBOPOS(x,y); | |
| 2438 | |||
| 2439 | ✗ | if(pos>175 || pos < 0) | |
| 2440 | ✗ | return 0; | |
| 2441 | |||
| 2442 | ✗ | return layer->data[pos]; | |
| 2443 | ✗ | } | |
| 2444 | |||
| 2445 | ✗ | int32_t zmap::MAPCOMBO(int32_t x,int32_t y, int32_t map, int32_t scr) //map=-1,scr=-1 | |
| 2446 | { | ||
| 2447 | ✗ | if(map<0) | |
| 2448 | ✗ | map=cursor.map; | |
| 2449 | |||
| 2450 | ✗ | if(scr<0) | |
| 2451 | ✗ | scr=cursor.screen; | |
| 2452 | |||
| 2453 | mapscr *screen1; | ||
| 2454 | |||
| 2455 | ✗ | if(prv_mode) | |
| 2456 | { | ||
| 2457 | ✗ | screen1=get_prvscr(); | |
| 2458 | ✗ | } | |
| 2459 | else | ||
| 2460 | { | ||
| 2461 | ✗ | screen1=AbsoluteScr(cursor.map,cursor.screen); | |
| 2462 | } | ||
| 2463 | |||
| 2464 | ✗ | x = vbound(x, 0, 16*16); | |
| 2465 | ✗ | y = vbound(y, 0, 11*16); | |
| 2466 | ✗ | int32_t combo = COMBOPOS(x,y); | |
| 2467 | |||
| 2468 | ✗ | if(combo>175 || combo < 0) | |
| 2469 | ✗ | return 0; | |
| 2470 | |||
| 2471 | ✗ | return screen1->data[combo]; | |
| 2472 | ✗ | } | |
| 2473 | |||
| 2474 | ✗ | int32_t zmap::MAPFLAG3(int32_t map, int32_t screen, int32_t layer, int32_t x,int32_t y) | |
| 2475 | { | ||
| 2476 | ✗ | return MAPFLAG3(map, screen, layer, COMBOPOS(x,y)); | |
| 2477 | } | ||
| 2478 | |||
| 2479 | ✗ | int32_t zmap::MAPFLAG3(int32_t map, int32_t screen, int32_t layer, int32_t pos) | |
| 2480 | { | ||
| 2481 | ✗ | if (map < 0 || screen < 0) return 0; | |
| 2482 | |||
| 2483 | ✗ | if(pos>175 || pos < 0) | |
| 2484 | ✗ | return 0; | |
| 2485 | |||
| 2486 | ✗ | mapscr const* m = &TheMaps[(map*MAPSCRS)+screen]; | |
| 2487 | |||
| 2488 | ✗ | if (!m->is_valid()) return 0; | |
| 2489 | |||
| 2490 | ✗ | int32_t mapid = (layer < 0 ? -1 : ((m->layermap[layer] - 1) * MAPSCRS + m->layerscreen[layer])); | |
| 2491 | |||
| 2492 | ✗ | if (layer >= 0 && (mapid < 0 || mapid > MAXMAPS*MAPSCRS)) return 0; | |
| 2493 | |||
| 2494 | ✗ | mapscr const* scr = ((mapid < 0 || mapid > MAXMAPS*MAPSCRS) ? m : &TheMaps[mapid]); | |
| 2495 | |||
| 2496 | ✗ | if (!scr->is_valid()) return 0; | |
| 2497 | |||
| 2498 | ✗ | return scr->sflag[pos]; // entire combo code | |
| 2499 | ✗ | } | |
| 2500 | |||
| 2501 | ✗ | int32_t zmap::MAPFLAG2(int32_t lyr,int32_t x,int32_t y, int32_t map, int32_t scr) | |
| 2502 | { | ||
| 2503 | ✗ | if(lyr<=-1) return MAPFLAG(x,y,map,scr); | |
| 2504 | |||
| 2505 | ✗ | if(map<0) | |
| 2506 | ✗ | map=cursor.map; | |
| 2507 | |||
| 2508 | ✗ | if(scr<0) | |
| 2509 | ✗ | scr=cursor.screen; | |
| 2510 | |||
| 2511 | mapscr *screen1; | ||
| 2512 | |||
| 2513 | ✗ | if(prv_mode) | |
| 2514 | { | ||
| 2515 | ✗ | screen1=get_prvscr(); | |
| 2516 | ✗ | } | |
| 2517 | else | ||
| 2518 | { | ||
| 2519 | ✗ | screen1=AbsoluteScr(cursor.map,cursor.screen); | |
| 2520 | } | ||
| 2521 | |||
| 2522 | int32_t layermap; | ||
| 2523 | ✗ | layermap=screen1->layermap[lyr]-1; | |
| 2524 | |||
| 2525 | ✗ | if(layermap<0 || layermap >= map_count) return 0; | |
| 2526 | |||
| 2527 | mapscr *layer; | ||
| 2528 | |||
| 2529 | ✗ | if(prv_mode) | |
| 2530 | ✗ | layer = &prvlayers[lyr]; | |
| 2531 | else | ||
| 2532 | ✗ | layer = AbsoluteScr(layermap,screen1->layerscreen[lyr]); | |
| 2533 | |||
| 2534 | ✗ | int32_t combo = COMBOPOS(x,y); | |
| 2535 | |||
| 2536 | ✗ | if(combo>175 || combo < 0) | |
| 2537 | ✗ | return 0; | |
| 2538 | |||
| 2539 | ✗ | return layer->sflag[combo]; | |
| 2540 | ✗ | } | |
| 2541 | |||
| 2542 | ✗ | int32_t zmap::MAPFLAG(int32_t x,int32_t y, int32_t map, int32_t scr) //map=-1,scr=-1 | |
| 2543 | { | ||
| 2544 | ✗ | if(map<0) | |
| 2545 | ✗ | map=cursor.map; | |
| 2546 | |||
| 2547 | ✗ | if(scr<0) | |
| 2548 | ✗ | scr=cursor.screen; | |
| 2549 | |||
| 2550 | mapscr *screen1; | ||
| 2551 | |||
| 2552 | ✗ | if(prv_mode) | |
| 2553 | { | ||
| 2554 | ✗ | screen1=get_prvscr(); | |
| 2555 | ✗ | } | |
| 2556 | else | ||
| 2557 | { | ||
| 2558 | ✗ | screen1=AbsoluteScr(cursor.map,cursor.screen); | |
| 2559 | } | ||
| 2560 | |||
| 2561 | ✗ | x = vbound(x, 0, 16*16); | |
| 2562 | ✗ | y = vbound(y, 0, 11*16); | |
| 2563 | ✗ | int32_t combo = COMBOPOS(x,y); | |
| 2564 | |||
| 2565 | ✗ | if(combo>175 || combo < 0) | |
| 2566 | ✗ | return 0; | |
| 2567 | |||
| 2568 | ✗ | return screen1->sflag[combo]; | |
| 2569 | ✗ | } | |
| 2570 | |||
| 2571 | ✗ | void zmap::draw_darkness(BITMAP* dest, BITMAP* transdest) | |
| 2572 | { | ||
| 2573 | mapscr *layers[7]; | ||
| 2574 | mapscr *basescr; | ||
| 2575 | ✗ | if(prv_mode) | |
| 2576 | { | ||
| 2577 | ✗ | layers[0] = &prvscr; | |
| 2578 | ✗ | basescr = layers[0]; | |
| 2579 | ✗ | for(auto q = 1; q < 7; ++q) | |
| 2580 | { | ||
| 2581 | ✗ | if(prvlayers[q-1].valid) | |
| 2582 | ✗ | layers[q] = &(prvlayers[q-1]); | |
| 2583 | ✗ | else layers[q] = NULL; | |
| 2584 | ✗ | } | |
| 2585 | ✗ | } | |
| 2586 | else | ||
| 2587 | { | ||
| 2588 | ✗ | layers[0] = AbsoluteScr(cursor.map, cursor.screen); | |
| 2589 | ✗ | basescr = layers[0]; | |
| 2590 | ✗ | for(auto q = 1; q < 7; ++q) | |
| 2591 | { | ||
| 2592 | ✗ | int32_t lmap = basescr->layermap[q-1]-1; | |
| 2593 | ✗ | int32_t lscr = basescr->layerscreen[q-1]; | |
| 2594 | ✗ | if(lmap < 0) | |
| 2595 | ✗ | layers[q] = NULL; | |
| 2596 | ✗ | else layers[q] = AbsoluteScr(lmap, lscr); | |
| 2597 | ✗ | } | |
| 2598 | } | ||
| 2599 | ✗ | for(auto q = 0; q < 7; ++q) | |
| 2600 | { | ||
| 2601 | ✗ | if(!layers[q]) continue; | |
| 2602 | ✗ | for(auto pos = 0; pos < 176; ++pos) | |
| 2603 | { | ||
| 2604 | ✗ | newcombo const& cmb = combobuf[layers[q]->data[pos]]; | |
| 2605 | ✗ | if(cmb.type == cTORCH) | |
| 2606 | ✗ | do_torch_combo(cmb, COMBOX(pos)+8, COMBOY(pos)+8, dest, transdest); | |
| 2607 | ✗ | } | |
| 2608 | ✗ | } | |
| 2609 | ✗ | word maxffc = basescr->numFFC(); | |
| 2610 | ✗ | for(auto q = 0; q < maxffc; ++q) | |
| 2611 | { | ||
| 2612 | ✗ | newcombo const& cmb = combobuf[basescr->ffcs[q].data]; | |
| 2613 | ✗ | if(cmb.type == cTORCH) | |
| 2614 | ✗ | do_torch_combo(cmb, (basescr->ffcs[q].x.getInt())+(basescr->ffEffectWidth(q)/2), (basescr->ffcs[q].y.getInt())+(basescr->ffEffectHeight(q)/2), dest, transdest); | |
| 2615 | ✗ | } | |
| 2616 | ✗ | } | |
| 2617 | |||
| 2618 | ✗ | void drawcombo(BITMAP* dest, int32_t x, int32_t y, int32_t cid, int32_t cset, int32_t flags, | |
| 2619 | int32_t sflag, bool over = true, bool transp = false, bool dither = false) | ||
| 2620 | { | ||
| 2621 | ✗ | newcombo const& cmb = combobuf[cid]; | |
| 2622 | ✗ | if(cmb.animflags & AF_TRANSPARENT) transp = !transp; | |
| 2623 | ✗ | if(dither) | |
| 2624 | { | ||
| 2625 | ✗ | if (LayerDitherSz == 0) | |
| 2626 | ✗ | return; | |
| 2627 | ✗ | BITMAP* buf = create_bitmap_ex(8,16,16); | |
| 2628 | ✗ | clear_bitmap(buf); | |
| 2629 | ✗ | overcombo(buf,0,0,cid,cset); | |
| 2630 | ✗ | ditherblit(buf,nullptr,0,dithChecker,LayerDitherSz,x,y); | |
| 2631 | ✗ | if(over) | |
| 2632 | { | ||
| 2633 | ✗ | if(transp) | |
| 2634 | { | ||
| 2635 | ✗ | color_map = &trans_table2; | |
| 2636 | ✗ | draw_trans_sprite(dest, buf, x, y); | |
| 2637 | ✗ | color_map = &trans_table; | |
| 2638 | ✗ | } | |
| 2639 | ✗ | else masked_blit(buf, dest, 0, 0, x, y, 16, 16); | |
| 2640 | ✗ | } | |
| 2641 | ✗ | else masked_blit(buf, dest, 0, 0, x, y, 16, 16); | |
| 2642 | ✗ | destroy_bitmap(buf); | |
| 2643 | ✗ | } | |
| 2644 | ✗ | else if(over) | |
| 2645 | { | ||
| 2646 | ✗ | if(transp) | |
| 2647 | ✗ | overcombotranslucent(dest,x,y,cid,cset,0); | |
| 2648 | ✗ | else overcombo(dest,x,y,cid,cset); | |
| 2649 | ✗ | } | |
| 2650 | ✗ | else put_combo(dest,x,y,cid,cset,flags,sflag); | |
| 2651 | ✗ | } | |
| 2652 | ✗ | static void _zmap_drawlayer(BITMAP* dest, int32_t x, int32_t y, mapscr* md, int32_t flags, bool trans, bool over, bool dither, bool passflag = false) | |
| 2653 | { | ||
| 2654 | ✗ | if(!md) return; | |
| 2655 | ✗ | for (int32_t i = 0; i < 176; i++) | |
| 2656 | ✗ | drawcombo(dest, ((i&15)<<4)+x, (i&0xF0)+y, md->data[i], md->cset[i], flags, passflag ? md->sflag[i] : 0, over, trans, dither); | |
| 2657 | ✗ | } | |
| 2658 | ✗ | static void _zmap_drawlayer_ohead(BITMAP* dest, int32_t x, int32_t y, mapscr* md, int32_t flags, bool trans, bool dither) | |
| 2659 | { | ||
| 2660 | ✗ | if(!md) return; | |
| 2661 | ✗ | for (int32_t i = 0; i < 176; i++) | |
| 2662 | { | ||
| 2663 | ✗ | int data = md->data[i]; | |
| 2664 | ✗ | if(combo_class_buf[combobuf[data].type].overhead) | |
| 2665 | ✗ | drawcombo(dest, ((i&15)<<4)+x, (i&0xF0)+y, data, md->cset[i], 0, 0, true, trans, dither); | |
| 2666 | ✗ | } | |
| 2667 | ✗ | } | |
| 2668 | ✗ | static mapscr* _zmap_get_lyr_checked(int lyr, mapscr* basescr) | |
| 2669 | { | ||
| 2670 | ✗ | if(!LayerMaskInt[lyr]) | |
| 2671 | ✗ | return nullptr; | |
| 2672 | ✗ | if(lyr == 0) | |
| 2673 | ✗ | return basescr; | |
| 2674 | ✗ | int layermap = basescr->layermap[lyr-1]-1; | |
| 2675 | |||
| 2676 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 2677 | { | ||
| 2678 | ✗ | int layerscreen = layermap*MAPSCRS+basescr->layerscreen[lyr-1]; | |
| 2679 | ✗ | return &TheMaps[layerscreen]; | |
| 2680 | } | ||
| 2681 | ✗ | return nullptr; | |
| 2682 | ✗ | } | |
| 2683 | ✗ | void zmap::draw(BITMAP* dest,int32_t x,int32_t y,int32_t flags,int32_t map,int32_t screen,int32_t hl_layer) | |
| 2684 | { | ||
| 2685 | #define HL_LAYER(lyr) (!(NoHighlightLayer0 && hl_layer == 0) && hl_layer > -1 && hl_layer != lyr) | ||
| 2686 | ✗ | int32_t antiflags=(flags&~cFLAGS)&~cWALK; | |
| 2687 | |||
| 2688 | ✗ | if(map<0) | |
| 2689 | ✗ | map=cursor.map; | |
| 2690 | |||
| 2691 | ✗ | if(screen<0) | |
| 2692 | ✗ | screen=cursor.screen; | |
| 2693 | |||
| 2694 | mapscr *basescr; | ||
| 2695 | ✗ | mapscr* layers[7] = {nullptr}; | |
| 2696 | |||
| 2697 | ✗ | if(prv_mode) | |
| 2698 | { | ||
| 2699 | ✗ | hl_layer = -1; | |
| 2700 | ✗ | basescr=get_prvscr(); | |
| 2701 | ✗ | } | |
| 2702 | else | ||
| 2703 | { | ||
| 2704 | ✗ | basescr=AbsoluteScr(map,screen); | |
| 2705 | } | ||
| 2706 | ✗ | layers[0] = _zmap_get_lyr_checked(0,basescr); | |
| 2707 | ✗ | for(int lyr = 1; lyr < 7; ++lyr) | |
| 2708 | { | ||
| 2709 | ✗ | layers[lyr] = prv_mode ? ((&prvlayers[lyr-1])->valid ? &prvlayers[lyr - 1] : nullptr) | |
| 2710 | ✗ | : _zmap_get_lyr_checked(lyr,basescr); | |
| 2711 | ✗ | } | |
| 2712 | |||
| 2713 | int32_t layermap, layerscreen; | ||
| 2714 | ✗ | if(CurrentLayer < 1) | |
| 2715 | ✗ | layermap = -1; | |
| 2716 | else | ||
| 2717 | ✗ | layermap=basescr->layermap[CurrentLayer-1]-1; | |
| 2718 | |||
| 2719 | ✗ | if(!(basescr->valid&mVALID)) | |
| 2720 | { | ||
| 2721 | // rectfill(dest,x,y,x+255,y+175,dvc(0+1)); | ||
| 2722 | ✗ | rectfill(dest,x,y,x+255,y+175,vc(1)); | |
| 2723 | |||
| 2724 | ✗ | if(ShowMisalignments) | |
| 2725 | { | ||
| 2726 | ✗ | check_alignments(dest,x,y,screen); | |
| 2727 | ✗ | } | |
| 2728 | |||
| 2729 | ✗ | return; | |
| 2730 | } | ||
| 2731 | |||
| 2732 | ✗ | if(LayerMaskInt[0]==0) | |
| 2733 | { | ||
| 2734 | ✗ | byte bgfill = 0; | |
| 2735 | ✗ | if (LayerDitherBG > -1) | |
| 2736 | ✗ | bgfill = vc(LayerDitherBG); | |
| 2737 | ✗ | rectfill(dest,x,y,x+255,y+175,bgfill); | |
| 2738 | ✗ | } | |
| 2739 | |||
| 2740 | ✗ | if(XOR(basescr->flags7&fLAYER2BG,ViewLayer2BG)) | |
| 2741 | ✗ | _zmap_drawlayer(dest, x, y, layers[2], antiflags, false, false, HL_LAYER(2)); | |
| 2742 | |||
| 2743 | ✗ | if(XOR(basescr->flags7&fLAYER3BG,ViewLayer3BG)) | |
| 2744 | ✗ | _zmap_drawlayer(dest, x, y, layers[3], antiflags, basescr->layeropacity[3-1]!=255, XOR(basescr->flags7&fLAYER2BG,ViewLayer2BG), HL_LAYER(3)); | |
| 2745 | |||
| 2746 | ✗ | _zmap_drawlayer(dest, x, y, layers[0], antiflags, false, (XOR(basescr->flags7&fLAYER2BG,ViewLayer2BG)||XOR(basescr->flags7&fLAYER3BG,ViewLayer3BG)), HL_LAYER(0), true); | |
| 2747 | |||
| 2748 | ✗ | _zmap_drawlayer(dest, x, y, layers[1], antiflags, basescr->layeropacity[1-1]!=255, true, HL_LAYER(1)); | |
| 2749 | |||
| 2750 | ✗ | int num_ffcs = basescr->numFFC(); | |
| 2751 | ✗ | for(int32_t i=num_ffcs-1; i>=0; i--) | |
| 2752 | { | ||
| 2753 | ✗ | if(basescr->ffcs[i].data) | |
| 2754 | { | ||
| 2755 | ✗ | if(!(basescr->ffcs[i].flags&ffc_changer)) | |
| 2756 | { | ||
| 2757 | ✗ | if(!(basescr->ffcs[i].flags&ffc_overlay)) | |
| 2758 | { | ||
| 2759 | ✗ | int32_t tx=(basescr->ffcs[i].x.getInt())+x; | |
| 2760 | ✗ | int32_t ty=(basescr->ffcs[i].y.getInt())+y; | |
| 2761 | |||
| 2762 | ✗ | if(basescr->ffcs[i].flags&ffc_trans) | |
| 2763 | { | ||
| 2764 | ✗ | overcomboblocktranslucent(dest, tx, ty, basescr->ffcs[i].data, basescr->ffcs[i].cset,basescr->ffTileWidth(i), basescr->ffTileHeight(i),128); | |
| 2765 | //overtiletranslucent16(dest, combo_tile(basescr->ffcs[i].data,tx,ty)+(j*20)+(l), tx, ty, basescr->ffcs[i].cset, combobuf[basescr->ffcs[i].data].flip, 128); | ||
| 2766 | ✗ | } | |
| 2767 | else | ||
| 2768 | { | ||
| 2769 | ✗ | overcomboblock(dest, tx, ty, basescr->ffcs[i].data, basescr->ffcs[i].cset, basescr->ffTileWidth(i), basescr->ffTileHeight(i)); | |
| 2770 | //overtile16(dest, combo_tile(basescr->ffcs[i].data,tx,ty)+(j*20)+(l), tx, ty, basescr->ffcs[i].cset, combobuf[basescr->ffcs[i].data].flip); | ||
| 2771 | } | ||
| 2772 | ✗ | } | |
| 2773 | ✗ | } | |
| 2774 | ✗ | } | |
| 2775 | ✗ | } | |
| 2776 | |||
| 2777 | ✗ | if(!XOR(basescr->flags7&fLAYER2BG,ViewLayer2BG)) | |
| 2778 | ✗ | _zmap_drawlayer(dest, x, y, layers[2], antiflags, basescr->layeropacity[2-1]!=255, true, HL_LAYER(2)); | |
| 2779 | |||
| 2780 | int32_t doortype[4]; | ||
| 2781 | |||
| 2782 | ✗ | for(int32_t i=0; i<4; i++) | |
| 2783 | { | ||
| 2784 | ✗ | switch(basescr->door[i]) | |
| 2785 | { | ||
| 2786 | case dOPEN: | ||
| 2787 | ✗ | doortype[i]=dt_pass; | |
| 2788 | ✗ | break; | |
| 2789 | |||
| 2790 | case dLOCKED: | ||
| 2791 | ✗ | doortype[i]=dt_lock; | |
| 2792 | ✗ | break; | |
| 2793 | |||
| 2794 | case d1WAYSHUTTER: | ||
| 2795 | case dSHUTTER: | ||
| 2796 | ✗ | doortype[i]=dt_shut; | |
| 2797 | ✗ | break; | |
| 2798 | |||
| 2799 | case dBOSS: | ||
| 2800 | ✗ | doortype[i]=dt_boss; | |
| 2801 | ✗ | break; | |
| 2802 | |||
| 2803 | case dBOMB: | ||
| 2804 | ✗ | doortype[i]=dt_bomb; | |
| 2805 | ✗ | break; | |
| 2806 | } | ||
| 2807 | ✗ | } | |
| 2808 | |||
| 2809 | ✗ | switch(basescr->door[up]) | |
| 2810 | { | ||
| 2811 | case dBOMB: | ||
| 2812 | ✗ | over_door(dest,39,up,x,y,false, screen); | |
| 2813 | [[fallthrough]]; | ||
| 2814 | case dOPEN: | ||
| 2815 | case dLOCKED: | ||
| 2816 | case d1WAYSHUTTER: | ||
| 2817 | case dSHUTTER: | ||
| 2818 | case dBOSS: | ||
| 2819 | ✗ | put_door(dest,7,up,doortype[up],x,y,false,screen); | |
| 2820 | ✗ | break; | |
| 2821 | |||
| 2822 | case dWALK: | ||
| 2823 | ✗ | if(get_bit(DoorComboSets[screens[cursor.screen].door_combo_set].flags,df_walktrans)) | |
| 2824 | { | ||
| 2825 | ✗ | overcombo(dest,((23&15)<<4)+8+x,(23&0xF0)+y, | |
| 2826 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcombo[0], | |
| 2827 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcset[0]); | |
| 2828 | ✗ | } | |
| 2829 | else | ||
| 2830 | |||
| 2831 | { | ||
| 2832 | ✗ | put_combo(dest,((23&15)<<4)+8+x,(23&0xF0)+y, | |
| 2833 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcombo[0], | |
| 2834 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcset[0],0,0); | |
| 2835 | } | ||
| 2836 | |||
| 2837 | ✗ | break; | |
| 2838 | } | ||
| 2839 | |||
| 2840 | ✗ | switch(basescr->door[down]) | |
| 2841 | { | ||
| 2842 | case dBOMB: | ||
| 2843 | ✗ | over_door(dest,135,down,x,y,false,screen); | |
| 2844 | [[fallthrough]]; | ||
| 2845 | case dOPEN: | ||
| 2846 | case dLOCKED: | ||
| 2847 | case d1WAYSHUTTER: | ||
| 2848 | case dSHUTTER: | ||
| 2849 | case dBOSS: | ||
| 2850 | ✗ | put_door(dest,151,down,doortype[down],x,y,false,screen); | |
| 2851 | ✗ | break; | |
| 2852 | |||
| 2853 | case dWALK: | ||
| 2854 | ✗ | if(get_bit(DoorComboSets[screens[cursor.screen].door_combo_set].flags,df_walktrans)) | |
| 2855 | { | ||
| 2856 | ✗ | overcombo(dest,((151&15)<<4)+8+x,(151&0xF0)+y, | |
| 2857 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcombo[1], | |
| 2858 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcset[1]); | |
| 2859 | ✗ | } | |
| 2860 | else | ||
| 2861 | { | ||
| 2862 | ✗ | put_combo(dest,((151&15)<<4)+8+x,(151&0xF0)+y, | |
| 2863 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcombo[1], | |
| 2864 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcset[1],0,0); | |
| 2865 | } | ||
| 2866 | |||
| 2867 | ✗ | break; | |
| 2868 | } | ||
| 2869 | |||
| 2870 | ✗ | switch(basescr->door[left]) | |
| 2871 | { | ||
| 2872 | case dBOMB: | ||
| 2873 | ✗ | over_door(dest,66,left,x,y,false,screen); | |
| 2874 | [[fallthrough]]; | ||
| 2875 | case dOPEN: | ||
| 2876 | case dLOCKED: | ||
| 2877 | case d1WAYSHUTTER: | ||
| 2878 | case dSHUTTER: | ||
| 2879 | case dBOSS: | ||
| 2880 | ✗ | put_door(dest,64,left,doortype[left],x,y,false,screen); | |
| 2881 | ✗ | break; | |
| 2882 | |||
| 2883 | case dWALK: | ||
| 2884 | ✗ | if(get_bit(DoorComboSets[screens[cursor.screen].door_combo_set].flags,df_walktrans)) | |
| 2885 | { | ||
| 2886 | ✗ | overcombo(dest,((81&15)<<4)+x,(81&0xF0)+y, | |
| 2887 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcombo[2], | |
| 2888 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcset[2]); | |
| 2889 | ✗ | } | |
| 2890 | else | ||
| 2891 | { | ||
| 2892 | ✗ | put_combo(dest,((81&15)<<4)+x,(81&0xF0)+y, | |
| 2893 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcombo[2], | |
| 2894 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcset[2],0,0); | |
| 2895 | } | ||
| 2896 | |||
| 2897 | ✗ | break; | |
| 2898 | } | ||
| 2899 | |||
| 2900 | ✗ | switch(basescr->door[right]) | |
| 2901 | { | ||
| 2902 | |||
| 2903 | case dBOMB: | ||
| 2904 | ✗ | over_door(dest,77,right,x,y,false,screen); | |
| 2905 | [[fallthrough]]; | ||
| 2906 | case dOPEN: | ||
| 2907 | case dLOCKED: | ||
| 2908 | case d1WAYSHUTTER: | ||
| 2909 | case dSHUTTER: | ||
| 2910 | case dBOSS: | ||
| 2911 | ✗ | put_door(dest,78,right,doortype[right],x,y,false,screen); | |
| 2912 | ✗ | break; | |
| 2913 | |||
| 2914 | case dWALK: | ||
| 2915 | ✗ | if(get_bit(DoorComboSets[screens[cursor.screen].door_combo_set].flags,df_walktrans)) | |
| 2916 | { | ||
| 2917 | ✗ | overcombo(dest,((94&15)<<4)+x,(94&0xF0)+y, | |
| 2918 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcombo[3], | |
| 2919 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcset[3]); | |
| 2920 | ✗ | } | |
| 2921 | else | ||
| 2922 | { | ||
| 2923 | ✗ | put_combo(dest,((94&15)<<4)+x,(94&0xF0)+y, | |
| 2924 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcombo[3], | |
| 2925 | ✗ | DoorComboSets[screens[cursor.screen].door_combo_set].walkthroughcset[3],0,0); | |
| 2926 | } | ||
| 2927 | |||
| 2928 | ✗ | break; | |
| 2929 | } | ||
| 2930 | |||
| 2931 | ✗ | if((basescr->hasitem != 0) && !(flags&cNOITEM)) | |
| 2932 | { | ||
| 2933 | ✗ | putitem2(dest,basescr->itemx+x,basescr->itemy+y+1-(get_qr(qr_NOITEMOFFSET)),basescr->item,lens_hint_item[basescr->item][0],lens_hint_item[basescr->item][1], 0); | |
| 2934 | ✗ | } | |
| 2935 | |||
| 2936 | ✗ | if(!XOR(basescr->flags7&fLAYER3BG,ViewLayer3BG)) | |
| 2937 | ✗ | _zmap_drawlayer(dest, x, y, layers[3], antiflags, basescr->layeropacity[3-1]!=255, true, HL_LAYER(3)); | |
| 2938 | ✗ | _zmap_drawlayer(dest, x, y, layers[4], antiflags, basescr->layeropacity[4-1]!=255, true, HL_LAYER(4)); | |
| 2939 | |||
| 2940 | ✗ | _zmap_drawlayer_ohead(dest, x, y, layers[0], antiflags, false, HL_LAYER(0)); | |
| 2941 | |||
| 2942 | ✗ | if(get_qr(qr_OVERHEAD_COMBOS_L1_L2)) | |
| 2943 | { | ||
| 2944 | ✗ | _zmap_drawlayer_ohead(dest, x, y, layers[1], antiflags, basescr->layeropacity[1-1]!=255, HL_LAYER(1)); | |
| 2945 | ✗ | _zmap_drawlayer_ohead(dest, x, y, layers[2], antiflags, basescr->layeropacity[2-1]!=255, HL_LAYER(2)); | |
| 2946 | ✗ | } | |
| 2947 | ✗ | _zmap_drawlayer(dest, x, y, layers[5], antiflags, basescr->layeropacity[5-1]!=255, true, HL_LAYER(5)); | |
| 2948 | |||
| 2949 | ✗ | for(int32_t i=num_ffcs-1; i>=0; i--) | |
| 2950 | { | ||
| 2951 | ✗ | if(basescr->ffcs[i].data) | |
| 2952 | { | ||
| 2953 | ✗ | if(!(basescr->ffcs[i].flags&ffc_changer)) | |
| 2954 | { | ||
| 2955 | ✗ | int32_t tx=(basescr->ffcs[i].x.getInt())+x; | |
| 2956 | ✗ | int32_t ty=(basescr->ffcs[i].y.getInt())+y; | |
| 2957 | |||
| 2958 | ✗ | if(basescr->ffcs[i].flags&ffc_overlay) | |
| 2959 | { | ||
| 2960 | ✗ | if(basescr->ffcs[i].flags&ffc_trans) | |
| 2961 | { | ||
| 2962 | //overtiletranslucent16(dest, combo_tile(basescr->ffcs[i].data,tx,ty)+(j*20)+(l), tx, ty, basescr->ffcs[i].cset, combobuf[basescr->ffcs[i].data].flip, 128); | ||
| 2963 | ✗ | overcomboblocktranslucent(dest,tx,ty,basescr->ffcs[i].data, basescr->ffcs[i].cset, basescr->ffTileWidth(i), basescr->ffTileHeight(i),128); | |
| 2964 | ✗ | } | |
| 2965 | else | ||
| 2966 | { | ||
| 2967 | //overtile16(dest, combo_tile(basescr->ffcs[i].data,tx,ty)+(j*20)+(l), tx, ty, basescr->ffcs[i].cset, combobuf[basescr->ffcs[i].data].flip); | ||
| 2968 | ✗ | overcomboblock(dest, tx, ty, basescr->ffcs[i].data, basescr->ffcs[i].cset, basescr->ffTileWidth(i), basescr->ffTileHeight(i)); | |
| 2969 | } | ||
| 2970 | ✗ | } | |
| 2971 | ✗ | } | |
| 2972 | ✗ | } | |
| 2973 | ✗ | } | |
| 2974 | |||
| 2975 | ✗ | _zmap_drawlayer(dest, x, y, layers[6], antiflags, basescr->layeropacity[6-1]!=255, true, HL_LAYER(6)); | |
| 2976 | |||
| 2977 | ✗ | for(int32_t i=num_ffcs-1; i>=0; i--) | |
| 2978 | ✗ | if(basescr->ffcs[i].data) | |
| 2979 | ✗ | if(basescr->ffcs[i].flags&ffc_changer) | |
| 2980 | ✗ | putpixel(dest,(basescr->ffcs[i].x.getInt())+x,(basescr->ffcs[i].y.getInt())+y,vc(zc_oldrand()%16)); | |
| 2981 | |||
| 2982 | ✗ | if(flags&cWALK) | |
| 2983 | { | ||
| 2984 | ✗ | if(layers[0]) | |
| 2985 | ✗ | for(int32_t i=0; i<176; i++) | |
| 2986 | ✗ | put_walkflags(dest,((i&15)<<4)+x,(i&0xF0)+y,layers[0]->data[i], 0); | |
| 2987 | |||
| 2988 | ✗ | for(int32_t k=0; k<2; k++) | |
| 2989 | { | ||
| 2990 | ✗ | if(layers[k+1]) | |
| 2991 | ✗ | for(int32_t i=0; i<176; i++) | |
| 2992 | ✗ | put_walkflags(dest,((i&15)<<4)+x,(i&0xF0)+y,layers[k+1]->data[i], 0); | |
| 2993 | ✗ | } | |
| 2994 | ✗ | for(int32_t i=num_ffcs-1; i>=0; i--) | |
| 2995 | { | ||
| 2996 | ✗ | if(auto data = basescr->ffcs[i].data) | |
| 2997 | { | ||
| 2998 | ✗ | if(!(basescr->ffcs[i].flags&ffc_changer)) | |
| 2999 | { | ||
| 3000 | ✗ | newcombo const& cmb = combobuf[data]; | |
| 3001 | ✗ | int32_t tx=(basescr->ffcs[i].x.getInt())+x; | |
| 3002 | ✗ | int32_t ty=(basescr->ffcs[i].y.getInt())+y; | |
| 3003 | |||
| 3004 | ✗ | if(basescr->ffcs[i].flags&ffc_solid) | |
| 3005 | { | ||
| 3006 | ✗ | rectfill(dest, tx, ty, tx + basescr->ffEffectWidth(i) - 1, ty + basescr->ffEffectHeight(i) - 1, COLOR_SOLID); | |
| 3007 | ✗ | } | |
| 3008 | |||
| 3009 | ✗ | if(cmb.type == cSLOPE) | |
| 3010 | { | ||
| 3011 | ✗ | slope_info s(cmb, tx, ty); | |
| 3012 | ✗ | s.draw(dest, 0, 0, COLOR_SLOPE); | |
| 3013 | ✗ | } | |
| 3014 | ✗ | } | |
| 3015 | ✗ | } | |
| 3016 | ✗ | } | |
| 3017 | ✗ | } | |
| 3018 | |||
| 3019 | ✗ | if(flags&cFLAGS) | |
| 3020 | { | ||
| 3021 | ✗ | if(LayerMaskInt[CurrentLayer]!=0) | |
| 3022 | { | ||
| 3023 | ✗ | for(int32_t i=0; i<176; i++) | |
| 3024 | { | ||
| 3025 | ✗ | if(CurrentLayer==0) | |
| 3026 | { | ||
| 3027 | ✗ | put_flags(dest,((i&15)<<4)+x,(i&0xF0)+y,basescr->data[i],basescr->cset[i],flags,basescr->sflag[i]); | |
| 3028 | ✗ | } | |
| 3029 | else | ||
| 3030 | { | ||
| 3031 | ✗ | if(prv_mode) | |
| 3032 | { | ||
| 3033 | ✗ | put_flags(dest,((i&15)<<4)+x,(i&0xF0)+y,prvlayers[CurrentLayer-1].data[i],prvlayers[CurrentLayer-1].cset[i],flags,prvlayers[CurrentLayer-1].sflag[i]); | |
| 3034 | ✗ | } | |
| 3035 | ✗ | else if(basescr->layermap[CurrentLayer-1] > 0) | |
| 3036 | { | ||
| 3037 | ✗ | int32_t _lscr=(basescr->layermap[CurrentLayer-1]-1)*MAPSCRS+basescr->layerscreen[CurrentLayer-1]; | |
| 3038 | |||
| 3039 | ✗ | if(_lscr>-1 && _lscr<map_count*MAPSCRS) | |
| 3040 | { | ||
| 3041 | ✗ | put_flags(dest,((i&15)<<4)+x,(i&0xF0)+y, | |
| 3042 | ✗ | TheMaps[_lscr].data[i], | |
| 3043 | ✗ | TheMaps[_lscr].cset[i], flags, | |
| 3044 | ✗ | TheMaps[_lscr].sflag[i]); | |
| 3045 | ✗ | } | |
| 3046 | ✗ | } | |
| 3047 | } | ||
| 3048 | ✗ | } | |
| 3049 | ✗ | } | |
| 3050 | ✗ | } | |
| 3051 | |||
| 3052 | ✗ | int32_t dark = basescr->flags&cDARK; | |
| 3053 | |||
| 3054 | ✗ | if(dark && !(flags&cNODARK) | |
| 3055 | ✗ | && !((Flags&cNEWDARK) && get_qr(qr_NEW_DARKROOM))) | |
| 3056 | { | ||
| 3057 | ✗ | for(int32_t j=0; j<80; j++) | |
| 3058 | { | ||
| 3059 | ✗ | for(int32_t i=0; i<(80)-j; i++) | |
| 3060 | { | ||
| 3061 | ✗ | if(((i^j)&1)==0) | |
| 3062 | { | ||
| 3063 | ✗ | putpixel(dest,x+i,y+j,vc(blackout_color)); | |
| 3064 | ✗ | } | |
| 3065 | ✗ | } | |
| 3066 | ✗ | } | |
| 3067 | ✗ | } | |
| 3068 | |||
| 3069 | ✗ | if(ShowMisalignments) | |
| 3070 | { | ||
| 3071 | ✗ | check_alignments(dest,x,y,screen); | |
| 3072 | ✗ | } | |
| 3073 | ✗ | } | |
| 3074 | |||
| 3075 | ✗ | void zmap::drawrow(BITMAP* dest,int32_t x,int32_t y,int32_t flags,int32_t c,int32_t map,int32_t scr) | |
| 3076 | { | ||
| 3077 | ✗ | if(map<0) | |
| 3078 | ✗ | map=cursor.map; | |
| 3079 | |||
| 3080 | ✗ | if(scr<0) | |
| 3081 | ✗ | scr=cursor.screen; | |
| 3082 | |||
| 3083 | ✗ | mapscr* layer=AbsoluteScr(map,scr); | |
| 3084 | ✗ | int32_t layermap=0, layerscreen=0; | |
| 3085 | |||
| 3086 | ✗ | if(!(layer->valid&mVALID)) | |
| 3087 | { | ||
| 3088 | // rectfill(dest,x,y,x+255,y+15,dvc(0+1)); | ||
| 3089 | ✗ | rectfill(dest,x,y,x+255,y+15,vc(1)); | |
| 3090 | ✗ | return; | |
| 3091 | } | ||
| 3092 | |||
| 3093 | ✗ | int32_t dark = layer->flags&4; | |
| 3094 | |||
| 3095 | ✗ | if(LayerMaskInt[0]==0) | |
| 3096 | { | ||
| 3097 | ✗ | rectfill(dest,x,y,x+255,y+15,0); | |
| 3098 | ✗ | } | |
| 3099 | |||
| 3100 | |||
| 3101 | ✗ | for(int32_t k=1; k<3; k++) | |
| 3102 | { | ||
| 3103 | ✗ | if(LayerMaskInt[k+1]!=0 && (k==1)?(layer->flags7&fLAYER2BG):(layer->flags7&fLAYER3BG)) | |
| 3104 | { | ||
| 3105 | ✗ | layermap=layer->layermap[k]-1; | |
| 3106 | |||
| 3107 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3108 | { | ||
| 3109 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[2-1]; | |
| 3110 | |||
| 3111 | ✗ | for(int32_t i=c; i<(c&0xF0)+16; i++) | |
| 3112 | { | ||
| 3113 | ✗ | auto data = TheMaps[layerscreen].data[i]; | |
| 3114 | ✗ | auto cs = TheMaps[layerscreen].cset[i]; | |
| 3115 | ✗ | drawcombo(dest,((i&15)<<4)+x,y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3116 | ✗ | } | |
| 3117 | ✗ | } | |
| 3118 | ✗ | } | |
| 3119 | ✗ | } | |
| 3120 | |||
| 3121 | ✗ | if(LayerMaskInt[0]!=0) | |
| 3122 | { | ||
| 3123 | ✗ | for(int32_t i=c; i<(c&0xF0)+16; i++) | |
| 3124 | { | ||
| 3125 | ✗ | word cmbdat = (i < 176 ? layer->data[i] : 0); | |
| 3126 | ✗ | byte cmbcset = (i < 176 ? layer->cset[i] : 0); | |
| 3127 | ✗ | int32_t cmbflag = (i < 176 ? layer->sflag[i] : 0); | |
| 3128 | ✗ | drawcombo(dest,((i&15)<<4)+x,y,cmbdat,cmbcset,((flags|dark)&~cWALK), | |
| 3129 | ✗ | cmbflag,(layer->flags7&fLAYER3BG||layer->flags7&fLAYER2BG)); | |
| 3130 | ✗ | } | |
| 3131 | ✗ | } | |
| 3132 | |||
| 3133 | ✗ | for(int32_t k=0; k<2; k++) | |
| 3134 | { | ||
| 3135 | ✗ | if(LayerMaskInt[k+1]!=0 && !(k==1 && layer->flags7&fLAYER2BG)) | |
| 3136 | { | ||
| 3137 | ✗ | layermap=layer->layermap[k]-1; | |
| 3138 | |||
| 3139 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3140 | { | ||
| 3141 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3142 | |||
| 3143 | ✗ | for(int32_t i=c; i<(c&0xF0)+16; i++) | |
| 3144 | { | ||
| 3145 | ✗ | auto data = TheMaps[layerscreen].data[i]; | |
| 3146 | ✗ | auto cs = TheMaps[layerscreen].cset[i]; | |
| 3147 | ✗ | drawcombo(dest,((i&15)<<4)+x,y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3148 | ✗ | } | |
| 3149 | ✗ | } | |
| 3150 | ✗ | } | |
| 3151 | ✗ | } | |
| 3152 | |||
| 3153 | int32_t doortype[4]; | ||
| 3154 | |||
| 3155 | ✗ | for(int32_t i=0; i<4; i++) | |
| 3156 | { | ||
| 3157 | ✗ | switch(layer->door[i]) | |
| 3158 | { | ||
| 3159 | case dOPEN: | ||
| 3160 | ✗ | doortype[i]=dt_pass; | |
| 3161 | ✗ | break; | |
| 3162 | |||
| 3163 | case dLOCKED: | ||
| 3164 | ✗ | doortype[i]=dt_lock; | |
| 3165 | ✗ | break; | |
| 3166 | |||
| 3167 | case d1WAYSHUTTER: | ||
| 3168 | case dSHUTTER: | ||
| 3169 | ✗ | doortype[i]=dt_shut; | |
| 3170 | ✗ | break; | |
| 3171 | |||
| 3172 | case dBOSS: | ||
| 3173 | ✗ | doortype[i]=dt_boss; | |
| 3174 | ✗ | break; | |
| 3175 | |||
| 3176 | case dBOMB: | ||
| 3177 | ✗ | doortype[i]=dt_bomb; | |
| 3178 | ✗ | break; | |
| 3179 | } | ||
| 3180 | ✗ | } | |
| 3181 | |||
| 3182 | ✗ | if(c<16) | |
| 3183 | { | ||
| 3184 | ✗ | switch(layer->door[up]) | |
| 3185 | { | ||
| 3186 | case dBOMB: | ||
| 3187 | case dOPEN: | ||
| 3188 | case dLOCKED: | ||
| 3189 | case d1WAYSHUTTER: | ||
| 3190 | case dSHUTTER: | ||
| 3191 | case dBOSS: | ||
| 3192 | ✗ | put_door(dest,7,up,doortype[up],x,y+176,true,scr); | |
| 3193 | ✗ | break; | |
| 3194 | } | ||
| 3195 | ✗ | } | |
| 3196 | ✗ | else if(c>159) | |
| 3197 | { | ||
| 3198 | ✗ | switch(layer->door[down]) | |
| 3199 | { | ||
| 3200 | case dBOMB: | ||
| 3201 | case dOPEN: | ||
| 3202 | case dLOCKED: | ||
| 3203 | case d1WAYSHUTTER: | ||
| 3204 | case dSHUTTER: | ||
| 3205 | case dBOSS: | ||
| 3206 | ✗ | put_door(dest,151,down,doortype[down],x,y-16,true,scr); | |
| 3207 | ✗ | break; | |
| 3208 | } | ||
| 3209 | ✗ | } | |
| 3210 | |||
| 3211 | ✗ | for(int32_t k=2; k<4; k++) | |
| 3212 | { | ||
| 3213 | ✗ | if(LayerMaskInt[k+1]!=0 && !(k==2 && layer->flags7&fLAYER3BG)) | |
| 3214 | { | ||
| 3215 | ✗ | layermap=layer->layermap[k]-1; | |
| 3216 | |||
| 3217 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3218 | { | ||
| 3219 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3220 | |||
| 3221 | ✗ | for(int32_t i=c; i<(c&0xF0)+16; i++) | |
| 3222 | { | ||
| 3223 | ✗ | if(layer->layeropacity[k]<255) | |
| 3224 | { | ||
| 3225 | ✗ | overcombotranslucent(dest,((i&15)<<4)+x,y,TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],layer->layeropacity[k]); | |
| 3226 | ✗ | } | |
| 3227 | else | ||
| 3228 | { | ||
| 3229 | ✗ | overcombo(dest,((i&15)<<4)+x,y,TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]); | |
| 3230 | } | ||
| 3231 | ✗ | } | |
| 3232 | ✗ | } | |
| 3233 | ✗ | } | |
| 3234 | ✗ | } | |
| 3235 | |||
| 3236 | //Overhead L0 | ||
| 3237 | ✗ | if(LayerMaskInt[0]!=0) | |
| 3238 | { | ||
| 3239 | ✗ | for(int32_t i=c; i<(c&0xF0)+16; i++) | |
| 3240 | { | ||
| 3241 | ✗ | int32_t ct1=layer->data[i]; | |
| 3242 | ✗ | int32_t ct3=combobuf[ct1].type; | |
| 3243 | |||
| 3244 | ✗ | if(combo_class_buf[ct3].overhead) | |
| 3245 | { | ||
| 3246 | ✗ | drawcombo(dest,((i&15)<<4)+x,y,layer->data[i],layer->cset[i],0,0); | |
| 3247 | ✗ | } | |
| 3248 | ✗ | } | |
| 3249 | ✗ | } | |
| 3250 | |||
| 3251 | //Overhead L1/2 | ||
| 3252 | ✗ | if(get_qr(qr_OVERHEAD_COMBOS_L1_L2)) | |
| 3253 | { | ||
| 3254 | ✗ | for(int32_t k = 0; k < 2; ++k) | |
| 3255 | { | ||
| 3256 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3257 | { | ||
| 3258 | ✗ | layermap=layer->layermap[k]-1; | |
| 3259 | |||
| 3260 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3261 | { | ||
| 3262 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3263 | ✗ | for(int32_t i=c; i<(c&0xF0)+16; i++) | |
| 3264 | { | ||
| 3265 | ✗ | auto data = TheMaps[layerscreen].data[i]; | |
| 3266 | ✗ | if(!combo_class_buf[combobuf[data].type].overhead) continue; | |
| 3267 | ✗ | auto cs = TheMaps[layerscreen].cset[i]; | |
| 3268 | ✗ | drawcombo(dest,((i&15)<<4)+x,y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3269 | ✗ | } | |
| 3270 | ✗ | } | |
| 3271 | ✗ | } | |
| 3272 | ✗ | } | |
| 3273 | ✗ | } | |
| 3274 | |||
| 3275 | ✗ | for(int32_t k=4; k<6; k++) | |
| 3276 | { | ||
| 3277 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3278 | { | ||
| 3279 | ✗ | layermap=layer->layermap[k]-1; | |
| 3280 | |||
| 3281 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3282 | { | ||
| 3283 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3284 | |||
| 3285 | ✗ | for(int32_t i=c; i<(c&0xF0)+16; i++) | |
| 3286 | { | ||
| 3287 | ✗ | auto data = TheMaps[layerscreen].data[i]; | |
| 3288 | ✗ | auto cs = TheMaps[layerscreen].cset[i]; | |
| 3289 | ✗ | drawcombo(dest,((i&15)<<4)+x,y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3290 | ✗ | } | |
| 3291 | ✗ | } | |
| 3292 | ✗ | } | |
| 3293 | ✗ | } | |
| 3294 | |||
| 3295 | ✗ | if(flags&cWALK) | |
| 3296 | { | ||
| 3297 | ✗ | if(LayerMaskInt[0]!=0) | |
| 3298 | { | ||
| 3299 | ✗ | for(int32_t i=c; i<(c&0xF0)+16; i++) | |
| 3300 | { | ||
| 3301 | ✗ | put_walkflags_layered_external(dest,((i&15)<<4)+x,y,i, -1, map,scr); | |
| 3302 | ✗ | } | |
| 3303 | ✗ | } | |
| 3304 | |||
| 3305 | ✗ | for(int32_t k=0; k<2; k++) | |
| 3306 | { | ||
| 3307 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3308 | { | ||
| 3309 | ✗ | for(int32_t i=c; i<(c&0xF0)+16; i++) | |
| 3310 | { | ||
| 3311 | ✗ | put_walkflags_layered_external(dest,((i&15)<<4)+x,y,i, k, map,scr); | |
| 3312 | ✗ | } | |
| 3313 | ✗ | } | |
| 3314 | ✗ | } | |
| 3315 | ✗ | } | |
| 3316 | |||
| 3317 | ✗ | if(flags&cFLAGS) | |
| 3318 | { | ||
| 3319 | ✗ | if(LayerMaskInt[CurrentLayer]!=0) | |
| 3320 | { | ||
| 3321 | ✗ | for(int32_t i=c; i<(c&0xF0)+16; i++) | |
| 3322 | { | ||
| 3323 | ✗ | if(CurrentLayer==0) | |
| 3324 | { | ||
| 3325 | ✗ | put_flags(dest,((i&15)<<4)+x,/*(i&0xF0)+*/y,layer->data[i],layer->cset[i],flags|dark,layer->sflag[i]); | |
| 3326 | ✗ | } | |
| 3327 | else | ||
| 3328 | { | ||
| 3329 | ✗ | int32_t _lscr=(layer->layermap[CurrentLayer-1]-1)*MAPSCRS+layer->layerscreen[CurrentLayer-1]; | |
| 3330 | |||
| 3331 | ✗ | if(_lscr>-1 && _lscr<map_count*MAPSCRS) | |
| 3332 | { | ||
| 3333 | ✗ | if(i < 176) | |
| 3334 | { | ||
| 3335 | ✗ | put_flags(dest,((i&15)<<4)+x,/*(i&0xF0)+*/y, | |
| 3336 | ✗ | TheMaps[_lscr].data[i], | |
| 3337 | ✗ | TheMaps[_lscr].cset[i], flags|dark, | |
| 3338 | ✗ | TheMaps[_lscr].sflag[i]); | |
| 3339 | ✗ | } | |
| 3340 | else | ||
| 3341 | { | ||
| 3342 | ✗ | put_flags(dest,((i&15)<<4)+x,/*(i&0xF0)+*/y,0,0, flags|dark,0); | |
| 3343 | } | ||
| 3344 | ✗ | } | |
| 3345 | } | ||
| 3346 | ✗ | } | |
| 3347 | ✗ | } | |
| 3348 | |||
| 3349 | /* | ||
| 3350 | if (LayerMaskInt[0]!=0) { | ||
| 3351 | for(int32_t i=c; i<(c&0xF0)+16; i++) { | ||
| 3352 | put_flags(dest,((i&15)<<4)+x,y,layer->data[i],layer->cset[i],flags|dark,layer->sflag[i]); | ||
| 3353 | } | ||
| 3354 | } | ||
| 3355 | */ | ||
| 3356 | ✗ | } | |
| 3357 | |||
| 3358 | ✗ | if(ShowMisalignments) | |
| 3359 | { | ||
| 3360 | ✗ | if(c<16) | |
| 3361 | { | ||
| 3362 | ✗ | check_alignments(dest,x,y,scr); | |
| 3363 | ✗ | } | |
| 3364 | ✗ | else if(c>159) | |
| 3365 | { | ||
| 3366 | ✗ | check_alignments(dest,x,y-160,scr); | |
| 3367 | ✗ | } | |
| 3368 | ✗ | } | |
| 3369 | ✗ | } | |
| 3370 | |||
| 3371 | ✗ | void zmap::drawcolumn(BITMAP* dest,int32_t x,int32_t y,int32_t flags,int32_t c,int32_t map,int32_t scr) | |
| 3372 | { | ||
| 3373 | ✗ | if(map<0) | |
| 3374 | ✗ | map=cursor.map; | |
| 3375 | |||
| 3376 | ✗ | if(scr<0) | |
| 3377 | ✗ | scr=cursor.screen; | |
| 3378 | |||
| 3379 | ✗ | mapscr* layer=AbsoluteScr(map,scr); | |
| 3380 | ✗ | int32_t layermap=0, layerscreen=0; | |
| 3381 | |||
| 3382 | ✗ | if(!(layer->valid&mVALID)) | |
| 3383 | { | ||
| 3384 | // rectfill(dest,x,y,x+15,y+175,dvc(0+1)); | ||
| 3385 | ✗ | rectfill(dest,x,y,x+15,y+175,vc(1)); | |
| 3386 | ✗ | return; | |
| 3387 | } | ||
| 3388 | |||
| 3389 | ✗ | int32_t dark = layer->flags&4; | |
| 3390 | |||
| 3391 | ✗ | if(LayerMaskInt[0]==0) | |
| 3392 | { | ||
| 3393 | ✗ | rectfill(dest,x,y,x+15,y+175,0); | |
| 3394 | ✗ | } | |
| 3395 | |||
| 3396 | |||
| 3397 | ✗ | for(int32_t k=1; k<3; k++) | |
| 3398 | { | ||
| 3399 | ✗ | if(LayerMaskInt[k+1]!=0 && (k==1)?(layer->flags7&fLAYER2BG):(layer->flags7&fLAYER3BG)) | |
| 3400 | { | ||
| 3401 | ✗ | layermap=layer->layermap[k]-1; | |
| 3402 | |||
| 3403 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3404 | { | ||
| 3405 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[2-1]; | |
| 3406 | |||
| 3407 | ✗ | for(int32_t i=c; i<176; i+=16) | |
| 3408 | { | ||
| 3409 | ✗ | auto data = TheMaps[layerscreen].data[i]; | |
| 3410 | ✗ | auto cs = TheMaps[layerscreen].cset[i]; | |
| 3411 | ✗ | drawcombo(dest,x,(i&0xF0)+y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3412 | ✗ | } | |
| 3413 | ✗ | } | |
| 3414 | ✗ | } | |
| 3415 | ✗ | } | |
| 3416 | |||
| 3417 | ✗ | if(LayerMaskInt[0]!=0) | |
| 3418 | { | ||
| 3419 | ✗ | for(int32_t i=c; i<176; i+=16) | |
| 3420 | { | ||
| 3421 | ✗ | word cmbdat = layer->data[i]; | |
| 3422 | ✗ | byte cmbcset = layer->cset[i]; | |
| 3423 | ✗ | int32_t cmbflag = layer->sflag[i]; | |
| 3424 | ✗ | drawcombo(dest,x,(i&0xF0)+y,cmbdat,cmbcset,((flags|dark)&~cWALK),cmbflag, | |
| 3425 | ✗ | (layer->flags7&fLAYER3BG||layer->flags7&fLAYER2BG)); | |
| 3426 | ✗ | } | |
| 3427 | ✗ | } | |
| 3428 | |||
| 3429 | ✗ | for(int32_t k=0; k<2; k++) | |
| 3430 | { | ||
| 3431 | ✗ | if(LayerMaskInt[k+1]!=0 && !(k==1 && layer->flags7&fLAYER2BG)) | |
| 3432 | { | ||
| 3433 | ✗ | layermap=layer->layermap[k]-1; | |
| 3434 | |||
| 3435 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3436 | { | ||
| 3437 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3438 | |||
| 3439 | ✗ | for(int32_t i=c; i<176; i+=16) | |
| 3440 | { | ||
| 3441 | ✗ | auto data = TheMaps[layerscreen].data[i]; | |
| 3442 | ✗ | auto cs = TheMaps[layerscreen].cset[i]; | |
| 3443 | ✗ | drawcombo(dest,x,(i&0xF0)+y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3444 | ✗ | } | |
| 3445 | ✗ | } | |
| 3446 | ✗ | } | |
| 3447 | ✗ | } | |
| 3448 | |||
| 3449 | int32_t doortype[4]; | ||
| 3450 | |||
| 3451 | ✗ | for(int32_t i=0; i<4; i++) | |
| 3452 | { | ||
| 3453 | ✗ | switch(layer->door[i]) | |
| 3454 | { | ||
| 3455 | case dOPEN: | ||
| 3456 | ✗ | doortype[i]=dt_pass; | |
| 3457 | ✗ | break; | |
| 3458 | |||
| 3459 | case dLOCKED: | ||
| 3460 | ✗ | doortype[i]=dt_lock; | |
| 3461 | ✗ | break; | |
| 3462 | |||
| 3463 | case d1WAYSHUTTER: | ||
| 3464 | case dSHUTTER: | ||
| 3465 | ✗ | doortype[i]=dt_shut; | |
| 3466 | ✗ | break; | |
| 3467 | |||
| 3468 | case dBOSS: | ||
| 3469 | ✗ | doortype[i]=dt_boss; | |
| 3470 | ✗ | break; | |
| 3471 | |||
| 3472 | case dBOMB: | ||
| 3473 | ✗ | doortype[i]=dt_bomb; | |
| 3474 | ✗ | break; | |
| 3475 | } | ||
| 3476 | ✗ | } | |
| 3477 | |||
| 3478 | ✗ | if((c&0x0F)==0) | |
| 3479 | { | ||
| 3480 | ✗ | switch(layer->door[left]) | |
| 3481 | { | ||
| 3482 | |||
| 3483 | case dBOMB: | ||
| 3484 | case dOPEN: | ||
| 3485 | case dLOCKED: | ||
| 3486 | case d1WAYSHUTTER: | ||
| 3487 | case dSHUTTER: | ||
| 3488 | case dBOSS: | ||
| 3489 | // put_door(dest,64,left,doortype[left],x+256,y,true); | ||
| 3490 | ✗ | put_door(dest,64,left,doortype[left],x,y,true,scr); | |
| 3491 | ✗ | break; | |
| 3492 | } | ||
| 3493 | ✗ | } | |
| 3494 | ✗ | else if((c&0x0F)==15) | |
| 3495 | { | ||
| 3496 | ✗ | switch(layer->door[right]) | |
| 3497 | { | ||
| 3498 | case dBOMB: | ||
| 3499 | case dOPEN: | ||
| 3500 | case dLOCKED: | ||
| 3501 | case d1WAYSHUTTER: | ||
| 3502 | case dSHUTTER: | ||
| 3503 | case dBOSS: | ||
| 3504 | ✗ | put_door(dest,78,right,doortype[right],x-16,y,true,scr); | |
| 3505 | ✗ | break; | |
| 3506 | } | ||
| 3507 | ✗ | } | |
| 3508 | |||
| 3509 | ✗ | for(int32_t k=2; k<4; k++) | |
| 3510 | { | ||
| 3511 | ✗ | if(LayerMaskInt[k+1]!=0 && !(k==2 && layer->flags7&fLAYER3BG)) | |
| 3512 | { | ||
| 3513 | ✗ | layermap=layer->layermap[k]-1; | |
| 3514 | |||
| 3515 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3516 | { | ||
| 3517 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3518 | |||
| 3519 | ✗ | for(int32_t i=c; i<176; i+=16) | |
| 3520 | { | ||
| 3521 | ✗ | auto data = TheMaps[layerscreen].data[i]; | |
| 3522 | ✗ | auto cs = TheMaps[layerscreen].cset[i]; | |
| 3523 | ✗ | drawcombo(dest,x,(i&0xF0)+y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3524 | ✗ | } | |
| 3525 | ✗ | } | |
| 3526 | ✗ | } | |
| 3527 | ✗ | } | |
| 3528 | |||
| 3529 | //Overhead L0 | ||
| 3530 | ✗ | if(LayerMaskInt[0]!=0) | |
| 3531 | { | ||
| 3532 | ✗ | for(int32_t i=c; i<176; i+=16) | |
| 3533 | { | ||
| 3534 | ✗ | auto data = TheMaps[layerscreen].data[i]; | |
| 3535 | ✗ | if(!combo_class_buf[combobuf[data].type].overhead) continue; | |
| 3536 | ✗ | auto cs = TheMaps[layerscreen].cset[i]; | |
| 3537 | ✗ | drawcombo(dest,x,(i&0xF0)+y,data,cs,0,0); | |
| 3538 | ✗ | } | |
| 3539 | ✗ | } | |
| 3540 | //Overhead L1/2 | ||
| 3541 | ✗ | if(get_qr(qr_OVERHEAD_COMBOS_L1_L2)) | |
| 3542 | { | ||
| 3543 | ✗ | for(int32_t k = 0; k < 2; ++k) | |
| 3544 | { | ||
| 3545 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3546 | { | ||
| 3547 | ✗ | layermap=layer->layermap[k]-1; | |
| 3548 | |||
| 3549 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3550 | { | ||
| 3551 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3552 | ✗ | for(int32_t i=c; i<176; i+=16) | |
| 3553 | { | ||
| 3554 | ✗ | auto data = TheMaps[layerscreen].data[i]; | |
| 3555 | ✗ | if(!combo_class_buf[combobuf[data].type].overhead) continue; | |
| 3556 | ✗ | auto cs = TheMaps[layerscreen].cset[i]; | |
| 3557 | ✗ | drawcombo(dest,x,(i&0xF0)+y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3558 | ✗ | } | |
| 3559 | ✗ | } | |
| 3560 | ✗ | } | |
| 3561 | ✗ | } | |
| 3562 | ✗ | } | |
| 3563 | |||
| 3564 | |||
| 3565 | ✗ | for(int32_t k=4; k<6; k++) | |
| 3566 | { | ||
| 3567 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3568 | { | ||
| 3569 | ✗ | layermap=layer->layermap[k]-1; | |
| 3570 | |||
| 3571 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3572 | { | ||
| 3573 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3574 | |||
| 3575 | ✗ | for(int32_t i=c; i<176; i+=16) | |
| 3576 | { | ||
| 3577 | ✗ | auto data = TheMaps[layerscreen].data[i]; | |
| 3578 | ✗ | auto cs = TheMaps[layerscreen].cset[i]; | |
| 3579 | ✗ | drawcombo(dest,x,(i&0xF0)+y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3580 | ✗ | } | |
| 3581 | ✗ | } | |
| 3582 | ✗ | } | |
| 3583 | ✗ | } | |
| 3584 | |||
| 3585 | ✗ | if(flags&cWALK) | |
| 3586 | { | ||
| 3587 | ✗ | if(LayerMaskInt[0]!=0) | |
| 3588 | { | ||
| 3589 | ✗ | for(int32_t i=c&0xF; i<176; i+=16) | |
| 3590 | { | ||
| 3591 | ✗ | put_walkflags_layered_external(dest,x,y+(i&0xF0),i, -1, map,scr); | |
| 3592 | ✗ | } | |
| 3593 | ✗ | } | |
| 3594 | |||
| 3595 | ✗ | for(int32_t k=0; k<2; k++) | |
| 3596 | { | ||
| 3597 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3598 | { | ||
| 3599 | ✗ | for(int32_t i=c&0xF; i<176; i+=16) | |
| 3600 | { | ||
| 3601 | ✗ | put_walkflags_layered_external(dest,x,y+(i&0xF0),i, k, map,scr); | |
| 3602 | ✗ | } | |
| 3603 | ✗ | } | |
| 3604 | ✗ | } | |
| 3605 | ✗ | } | |
| 3606 | |||
| 3607 | ✗ | if(flags&cFLAGS) | |
| 3608 | { | ||
| 3609 | ✗ | if(LayerMaskInt[CurrentLayer]!=0) | |
| 3610 | { | ||
| 3611 | ✗ | for(int32_t i=c; i<176; i+=16) | |
| 3612 | { | ||
| 3613 | ✗ | if(CurrentLayer==0) | |
| 3614 | { | ||
| 3615 | ✗ | put_flags(dest,/*((i&15)<<4)+*/x,(i&0xF0)+y,layer->data[i],layer->cset[i],flags|dark,layer->sflag[i]); | |
| 3616 | ✗ | } | |
| 3617 | else | ||
| 3618 | { | ||
| 3619 | ✗ | int32_t _lscr=(layer->layermap[CurrentLayer-1]-1)*MAPSCRS+layer->layerscreen[CurrentLayer-1]; | |
| 3620 | |||
| 3621 | ✗ | if(_lscr>-1 && _lscr<map_count*MAPSCRS) | |
| 3622 | { | ||
| 3623 | ✗ | put_flags(dest,/*((i&15)<<4)+*/x,(i&0xF0)+y, | |
| 3624 | ✗ | TheMaps[_lscr].data[i], | |
| 3625 | ✗ | TheMaps[_lscr].cset[i], flags|dark, | |
| 3626 | ✗ | TheMaps[_lscr].sflag[i]); | |
| 3627 | ✗ | } | |
| 3628 | } | ||
| 3629 | ✗ | } | |
| 3630 | ✗ | } | |
| 3631 | ✗ | } | |
| 3632 | |||
| 3633 | ✗ | if(ShowMisalignments) | |
| 3634 | { | ||
| 3635 | ✗ | if((c&0x0F)==0) | |
| 3636 | { | ||
| 3637 | ✗ | check_alignments(dest,x,y,scr); | |
| 3638 | ✗ | } | |
| 3639 | ✗ | else if((c&0x0F)==15) | |
| 3640 | { | ||
| 3641 | ✗ | check_alignments(dest,x-240,y,scr); | |
| 3642 | ✗ | } | |
| 3643 | ✗ | } | |
| 3644 | ✗ | } | |
| 3645 | |||
| 3646 | ✗ | void zmap::drawblock(BITMAP* dest,int32_t x,int32_t y,int32_t flags,int32_t c,int32_t map,int32_t scr) | |
| 3647 | { | ||
| 3648 | ✗ | if(map<0) | |
| 3649 | ✗ | map=cursor.map; | |
| 3650 | |||
| 3651 | ✗ | if(scr<0) | |
| 3652 | ✗ | scr=cursor.screen; | |
| 3653 | |||
| 3654 | ✗ | mapscr* layer=AbsoluteScr(map,scr); | |
| 3655 | ✗ | int32_t layermap=0, layerscreen=0; | |
| 3656 | |||
| 3657 | ✗ | if(!(layer->valid&mVALID)) | |
| 3658 | { | ||
| 3659 | // rectfill(dest,x,y,x+15,y+15,dvc(0+1)); | ||
| 3660 | ✗ | rectfill(dest,x,y,x+15,y+15,vc(1)); | |
| 3661 | ✗ | return; | |
| 3662 | } | ||
| 3663 | |||
| 3664 | ✗ | int32_t dark = layer->flags&4; | |
| 3665 | |||
| 3666 | ✗ | if(LayerMaskInt[0]!=0) | |
| 3667 | { | ||
| 3668 | ✗ | rectfill(dest,x,y,x+15,y+15,0); | |
| 3669 | ✗ | } | |
| 3670 | |||
| 3671 | ✗ | for(int32_t k=1; k<3; k++) | |
| 3672 | { | ||
| 3673 | ✗ | if(LayerMaskInt[k+1]!=0 && (k==1)?(layer->flags7&fLAYER2BG):(layer->flags7&fLAYER3BG)) | |
| 3674 | { | ||
| 3675 | ✗ | layermap=layer->layermap[k]-1; | |
| 3676 | |||
| 3677 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3678 | { | ||
| 3679 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[2-1]; | |
| 3680 | |||
| 3681 | ✗ | auto data = TheMaps[layerscreen].data[c]; | |
| 3682 | ✗ | auto cs = TheMaps[layerscreen].cset[c]; | |
| 3683 | ✗ | drawcombo(dest,x,y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3684 | ✗ | } | |
| 3685 | ✗ | } | |
| 3686 | ✗ | } | |
| 3687 | |||
| 3688 | ✗ | if(LayerMaskInt[0]!=0) | |
| 3689 | { | ||
| 3690 | ✗ | word cmbdat = layer->data[c]; | |
| 3691 | ✗ | byte cmbcset = layer->cset[c]; | |
| 3692 | ✗ | int32_t cmbflag = layer->sflag[c]; | |
| 3693 | ✗ | drawcombo(dest,x,y,cmbdat,cmbcset,((flags|dark)&~cWALK),cmbflag, | |
| 3694 | ✗ | (layer->flags7&fLAYER3BG||layer->flags7&fLAYER2BG)); | |
| 3695 | ✗ | } | |
| 3696 | |||
| 3697 | |||
| 3698 | ✗ | for(int32_t k=0; k<2; k++) | |
| 3699 | { | ||
| 3700 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3701 | { | ||
| 3702 | ✗ | layermap=layer->layermap[k]-1; | |
| 3703 | |||
| 3704 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3705 | { | ||
| 3706 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3707 | |||
| 3708 | ✗ | auto data = TheMaps[layerscreen].data[c]; | |
| 3709 | ✗ | auto cs = TheMaps[layerscreen].cset[c]; | |
| 3710 | ✗ | drawcombo(dest,x,y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3711 | ✗ | } | |
| 3712 | ✗ | } | |
| 3713 | ✗ | } | |
| 3714 | |||
| 3715 | ✗ | for(int32_t k=2; k<4; k++) | |
| 3716 | { | ||
| 3717 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3718 | { | ||
| 3719 | ✗ | layermap=layer->layermap[k]-1; | |
| 3720 | |||
| 3721 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3722 | { | ||
| 3723 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3724 | ✗ | auto data = TheMaps[layerscreen].data[c]; | |
| 3725 | ✗ | auto cs = TheMaps[layerscreen].cset[c]; | |
| 3726 | ✗ | drawcombo(dest,x,y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3727 | ✗ | } | |
| 3728 | ✗ | } | |
| 3729 | ✗ | } | |
| 3730 | |||
| 3731 | //Overhead L0 | ||
| 3732 | ✗ | if(LayerMaskInt[0]!=0) | |
| 3733 | { | ||
| 3734 | ✗ | auto data = TheMaps[layerscreen].data[c]; | |
| 3735 | ✗ | if(combo_class_buf[combobuf[data].type].overhead) | |
| 3736 | { | ||
| 3737 | ✗ | auto cs = TheMaps[layerscreen].cset[c]; | |
| 3738 | ✗ | drawcombo(dest,x,y,data,cs,0,0); | |
| 3739 | ✗ | } | |
| 3740 | ✗ | } | |
| 3741 | //Overhead L1/2 | ||
| 3742 | ✗ | if(get_qr(qr_OVERHEAD_COMBOS_L1_L2)) | |
| 3743 | { | ||
| 3744 | ✗ | for(int32_t k = 0; k < 2; ++k) | |
| 3745 | { | ||
| 3746 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3747 | { | ||
| 3748 | ✗ | layermap=layer->layermap[k]-1; | |
| 3749 | |||
| 3750 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3751 | { | ||
| 3752 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3753 | ✗ | auto data = TheMaps[layerscreen].data[c]; | |
| 3754 | ✗ | if(!combo_class_buf[combobuf[data].type].overhead) continue; | |
| 3755 | ✗ | auto cs = TheMaps[layerscreen].cset[c]; | |
| 3756 | ✗ | drawcombo(dest,x,y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3757 | ✗ | } | |
| 3758 | ✗ | } | |
| 3759 | ✗ | } | |
| 3760 | ✗ | } | |
| 3761 | |||
| 3762 | |||
| 3763 | ✗ | for(int32_t k=4; k<6; k++) | |
| 3764 | { | ||
| 3765 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3766 | { | ||
| 3767 | ✗ | layermap=layer->layermap[k]-1; | |
| 3768 | |||
| 3769 | ✗ | if(layermap>-1 && layermap<map_count) | |
| 3770 | { | ||
| 3771 | ✗ | layerscreen=layermap*MAPSCRS+layer->layerscreen[k]; | |
| 3772 | ✗ | auto data = TheMaps[layerscreen].data[c]; | |
| 3773 | ✗ | auto cs = TheMaps[layerscreen].cset[c]; | |
| 3774 | ✗ | drawcombo(dest,x,y,data,cs,0,0,true,layer->layeropacity[k]!=255); | |
| 3775 | ✗ | } | |
| 3776 | ✗ | } | |
| 3777 | ✗ | } | |
| 3778 | |||
| 3779 | ✗ | if(flags&cWALK) | |
| 3780 | { | ||
| 3781 | ✗ | if(LayerMaskInt[0]!=0) | |
| 3782 | { | ||
| 3783 | ✗ | put_walkflags_layered_external(dest,x,y,c,-1, map,scr); | |
| 3784 | ✗ | } | |
| 3785 | |||
| 3786 | ✗ | for(int32_t k=0; k<2; k++) | |
| 3787 | { | ||
| 3788 | ✗ | if(LayerMaskInt[k+1]!=0) | |
| 3789 | { | ||
| 3790 | ✗ | put_walkflags_layered_external(dest,x,y,c,k, map,scr); | |
| 3791 | ✗ | } | |
| 3792 | ✗ | } | |
| 3793 | ✗ | } | |
| 3794 | |||
| 3795 | ✗ | if(flags&cFLAGS) | |
| 3796 | { | ||
| 3797 | ✗ | if(LayerMaskInt[CurrentLayer]!=0) | |
| 3798 | { | ||
| 3799 | ✗ | int32_t i = c; | |
| 3800 | //for(int32_t i=c; i==c; i++) | ||
| 3801 | { | ||
| 3802 | ✗ | if(CurrentLayer==0) | |
| 3803 | { | ||
| 3804 | ✗ | put_flags(dest,/*((i&15)<<4)+*/x,/*(i&0xF0)+*/y,layer->data[i],layer->cset[i],flags|dark,layer->sflag[i]); | |
| 3805 | ✗ | } | |
| 3806 | else | ||
| 3807 | { | ||
| 3808 | ✗ | int32_t _lscr=(layer->layermap[CurrentLayer-1]-1)*MAPSCRS+layer->layerscreen[CurrentLayer-1]; | |
| 3809 | |||
| 3810 | ✗ | if(_lscr>-1 && _lscr<map_count*MAPSCRS) | |
| 3811 | { | ||
| 3812 | ✗ | put_flags(dest,/*((i&15)<<4)+*/x,/*(i&0xF0)+*/y, | |
| 3813 | ✗ | TheMaps[_lscr].data[i], | |
| 3814 | ✗ | TheMaps[_lscr].cset[i], flags|dark, | |
| 3815 | ✗ | TheMaps[_lscr].sflag[i]); | |
| 3816 | ✗ | } | |
| 3817 | } | ||
| 3818 | } | ||
| 3819 | ✗ | } | |
| 3820 | ✗ | } | |
| 3821 | |||
| 3822 | ✗ | if(ShowMisalignments) | |
| 3823 | { | ||
| 3824 | ✗ | switch(c) | |
| 3825 | { | ||
| 3826 | case 0: | ||
| 3827 | ✗ | check_alignments(dest,x,y,scr); | |
| 3828 | ✗ | break; | |
| 3829 | |||
| 3830 | case 15: | ||
| 3831 | ✗ | check_alignments(dest,x-240,y,scr); | |
| 3832 | ✗ | break; | |
| 3833 | |||
| 3834 | case 160: | ||
| 3835 | ✗ | check_alignments(dest,x,y-160,scr); | |
| 3836 | ✗ | break; | |
| 3837 | |||
| 3838 | case 175: | ||
| 3839 | ✗ | check_alignments(dest,x-240,y-160,scr); | |
| 3840 | ✗ | break; | |
| 3841 | } | ||
| 3842 | ✗ | } | |
| 3843 | ✗ | } | |
| 3844 | |||
| 3845 | ✗ | void zmap::drawstaticblock(BITMAP* dest,int32_t x,int32_t y) | |
| 3846 | { | ||
| 3847 | ✗ | if (InvalidBG == 2) | |
| 3848 | { | ||
| 3849 | ✗ | draw_checkerboard(dest, x, y, 16); | |
| 3850 | ✗ | } | |
| 3851 | ✗ | else if(InvalidBG == 1) | |
| 3852 | { | ||
| 3853 | ✗ | for(int32_t dy=0; dy<16; dy++) | |
| 3854 | { | ||
| 3855 | ✗ | for(int32_t dx=0; dx<16; dx++) | |
| 3856 | { | ||
| 3857 | ✗ | dest->line[y+dy][x+dx]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7)); | |
| 3858 | ✗ | } | |
| 3859 | ✗ | } | |
| 3860 | ✗ | } | |
| 3861 | else | ||
| 3862 | { | ||
| 3863 | ✗ | rectfill(dest, x, y, x+15, y+15, vc(0)); | |
| 3864 | ✗ | rect(dest, x, y, x+15, y+15, vc(15)); | |
| 3865 | ✗ | line(dest, x, y, x+15, y+15, vc(15)); | |
| 3866 | ✗ | line(dest, x, y+15, x+15, y, vc(15)); | |
| 3867 | } | ||
| 3868 | ✗ | } | |
| 3869 | |||
| 3870 | ✗ | void zmap::drawstaticcolumn(BITMAP* dest,int32_t x,int32_t y) | |
| 3871 | { | ||
| 3872 | ✗ | if (InvalidBG == 2) | |
| 3873 | { | ||
| 3874 | ✗ | for(int32_t q = 0; q < 11; ++q) | |
| 3875 | ✗ | draw_checkerboard(dest, x, y + q * 16, 16); | |
| 3876 | ✗ | } | |
| 3877 | ✗ | else if(InvalidBG == 1) | |
| 3878 | { | ||
| 3879 | ✗ | for(int32_t dy=0; dy<176; dy++) | |
| 3880 | { | ||
| 3881 | ✗ | for(int32_t dx=0; dx<16; dx++) | |
| 3882 | { | ||
| 3883 | ✗ | dest->line[y+dy][x+dx]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7)); | |
| 3884 | ✗ | } | |
| 3885 | ✗ | } | |
| 3886 | ✗ | } | |
| 3887 | else | ||
| 3888 | { | ||
| 3889 | ✗ | rectfill(dest, x, y, x+15, y+175, vc(0)); | |
| 3890 | ✗ | rect(dest, x, y, x+15, y+175, vc(15)); | |
| 3891 | ✗ | line(dest, x, y, x+15, y+175, vc(15)); | |
| 3892 | ✗ | line(dest, x, y+175, x+15, y, vc(15)); | |
| 3893 | } | ||
| 3894 | ✗ | } | |
| 3895 | |||
| 3896 | ✗ | void zmap::drawstaticrow(BITMAP* dest,int32_t x,int32_t y) | |
| 3897 | { | ||
| 3898 | ✗ | if (InvalidBG == 2) | |
| 3899 | { | ||
| 3900 | ✗ | for (int32_t q = 0; q < 16; ++q) | |
| 3901 | ✗ | draw_checkerboard(dest, x + q * 16, y, 16); | |
| 3902 | ✗ | } | |
| 3903 | ✗ | else if(InvalidBG == 1) | |
| 3904 | { | ||
| 3905 | ✗ | for(int32_t dy=0; dy<16; dy++) | |
| 3906 | { | ||
| 3907 | ✗ | for(int32_t dx=0; dx<256; dx++) | |
| 3908 | { | ||
| 3909 | ✗ | dest->line[y+dy][x+dx]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7)); | |
| 3910 | ✗ | } | |
| 3911 | ✗ | } | |
| 3912 | ✗ | } | |
| 3913 | else | ||
| 3914 | { | ||
| 3915 | ✗ | rectfill(dest, x, y, x+255, y+15, vc(0)); | |
| 3916 | ✗ | rect(dest, x, y, x+255, y+15, vc(15)); | |
| 3917 | ✗ | line(dest, x, y, x+255, y+15, vc(15)); | |
| 3918 | ✗ | line(dest, x, y+15, x+255, y, vc(15)); | |
| 3919 | } | ||
| 3920 | ✗ | } | |
| 3921 | |||
| 3922 | ✗ | void zmap::draw_template(BITMAP* dest,int32_t x,int32_t y) | |
| 3923 | { | ||
| 3924 | ✗ | for(int32_t i=0; i<176; i++) | |
| 3925 | { | ||
| 3926 | ✗ | word cmbdat = screens[TEMPLATE].data[i]; | |
| 3927 | ✗ | byte cmbcset = screens[TEMPLATE].cset[i]; | |
| 3928 | ✗ | int32_t cmbflag = screens[TEMPLATE].sflag[i]; | |
| 3929 | ✗ | put_combo(dest,((i&15)<<4)+x,(i&0xF0)+y,cmbdat,cmbcset,0,cmbflag); | |
| 3930 | ✗ | } | |
| 3931 | ✗ | } | |
| 3932 | |||
| 3933 | ✗ | void zmap::draw_template2(BITMAP* dest,int32_t x,int32_t y) | |
| 3934 | { | ||
| 3935 | ✗ | for(int32_t i=0; i<176; i++) | |
| 3936 | { | ||
| 3937 | ✗ | word cmbdat = screens[TEMPLATE2].data[i]; | |
| 3938 | ✗ | byte cmbcset = screens[TEMPLATE2].cset[i]; | |
| 3939 | ✗ | int32_t cmbflag = screens[TEMPLATE2].sflag[i]; | |
| 3940 | ✗ | put_combo(dest,((i&15)<<4)+x,(i&0xF0)+y,cmbdat,cmbcset,0,cmbflag); | |
| 3941 | ✗ | } | |
| 3942 | ✗ | } | |
| 3943 | |||
| 3944 | ✗ | void zmap::draw_secret(BITMAP *dest, int32_t pos) | |
| 3945 | { | ||
| 3946 | ✗ | word cmbdat = screens[TEMPLATE].data[pos]; | |
| 3947 | ✗ | byte cmbcset = screens[TEMPLATE].cset[pos]; | |
| 3948 | ✗ | int32_t cmbflag = screens[TEMPLATE].sflag[pos]; | |
| 3949 | ✗ | put_combo(dest,0,0,cmbdat,cmbcset,0,cmbflag); | |
| 3950 | ✗ | } | |
| 3951 | |||
| 3952 | ✗ | void zmap::draw_secret2(BITMAP *dest, int32_t scombo) | |
| 3953 | { | ||
| 3954 | ✗ | word cmbdat = screens[cursor.screen].secretcombo[scombo]; | |
| 3955 | ✗ | byte cmbcset = screens[cursor.screen].secretcset[scombo]; | |
| 3956 | ✗ | byte cmbflag = screens[cursor.screen].secretflag[scombo]; | |
| 3957 | ✗ | put_combo(dest,0,0,cmbdat,cmbcset,0,cmbflag); | |
| 3958 | ✗ | } | |
| 3959 | |||
| 3960 | ✗ | void zmap::scroll(int32_t dir, bool warp) | |
| 3961 | { | ||
| 3962 | ✗ | if(cursor.map<map_count) | |
| 3963 | { | ||
| 3964 | ✗ | switch(dir) | |
| 3965 | { | ||
| 3966 | case up: | ||
| 3967 | ✗ | if(warp && Map.CurrScr()->flags2&wfUP) | |
| 3968 | { | ||
| 3969 | ✗ | dowarp(1,Map.CurrScr()->sidewarpindex&3); | |
| 3970 | ✗ | } | |
| 3971 | ✗ | else if(cursor.screen>15) | |
| 3972 | { | ||
| 3973 | ✗ | setCurrScr(cursor.screen - 16); | |
| 3974 | ✗ | } | |
| 3975 | |||
| 3976 | ✗ | break; | |
| 3977 | |||
| 3978 | case down: | ||
| 3979 | ✗ | if(warp && Map.CurrScr()->flags2&wfDOWN) | |
| 3980 | { | ||
| 3981 | ✗ | dowarp(1,(Map.CurrScr()->sidewarpindex>>2)&3); | |
| 3982 | ✗ | } | |
| 3983 | ✗ | else if(cursor.screen<MAPSCRS-16) | |
| 3984 | { | ||
| 3985 | ✗ | setCurrScr(cursor.screen + 16); | |
| 3986 | ✗ | } | |
| 3987 | |||
| 3988 | ✗ | break; | |
| 3989 | |||
| 3990 | case left: | ||
| 3991 | ✗ | if(warp && Map.CurrScr()->flags2&wfLEFT) | |
| 3992 | { | ||
| 3993 | ✗ | dowarp(1,(Map.CurrScr()->sidewarpindex>>4)&3); | |
| 3994 | ✗ | } | |
| 3995 | ✗ | else if(cursor.screen&15) | |
| 3996 | { | ||
| 3997 | ✗ | setCurrScr(cursor.screen - 1); | |
| 3998 | ✗ | } | |
| 3999 | |||
| 4000 | ✗ | break; | |
| 4001 | |||
| 4002 | case right: | ||
| 4003 | ✗ | if(warp && Map.CurrScr()->flags2&wfRIGHT) | |
| 4004 | { | ||
| 4005 | ✗ | dowarp(1,(Map.CurrScr()->sidewarpindex>>6)&3); | |
| 4006 | ✗ | } | |
| 4007 | ✗ | else if((cursor.screen&15)<15 && cursor.screen<MAPSCRS-1) | |
| 4008 | { | ||
| 4009 | ✗ | setCurrScr(cursor.screen + 1); | |
| 4010 | ✗ | } | |
| 4011 | |||
| 4012 | ✗ | break; | |
| 4013 | } | ||
| 4014 | ✗ | } | |
| 4015 | ✗ | } | |
| 4016 | |||
| 4017 | ✗ | void fetch_door(int side, int door, int dcs, word data[176], byte cset[176]) | |
| 4018 | { | ||
| 4019 | ✗ | switch(side) | |
| 4020 | { | ||
| 4021 | case up: | ||
| 4022 | ✗ | switch(door) | |
| 4023 | { | ||
| 4024 | case dWALL: | ||
| 4025 | case dBOMB: | ||
| 4026 | case dWALK: | ||
| 4027 | ✗ | data[7] = DoorComboSets[dcs].doorcombo_u[dt_wall][0]; | |
| 4028 | ✗ | cset[7] = DoorComboSets[dcs].doorcset_u[dt_wall][0]; | |
| 4029 | ✗ | data[8] = DoorComboSets[dcs].doorcombo_u[dt_wall][1]; | |
| 4030 | ✗ | cset[8] = DoorComboSets[dcs].doorcset_u[dt_wall][1]; | |
| 4031 | ✗ | data[23] = DoorComboSets[dcs].doorcombo_u[dt_wall][2]; | |
| 4032 | ✗ | cset[23] = DoorComboSets[dcs].doorcset_u[dt_wall][2]; | |
| 4033 | ✗ | data[24] = DoorComboSets[dcs].doorcombo_u[dt_wall][3]; | |
| 4034 | ✗ | cset[24] = DoorComboSets[dcs].doorcset_u[dt_wall][3]; | |
| 4035 | ✗ | break; | |
| 4036 | |||
| 4037 | default: | ||
| 4038 | ✗ | data[7] = DoorComboSets[dcs].doorcombo_u[dt_pass][0]; | |
| 4039 | ✗ | cset[7] = DoorComboSets[dcs].doorcset_u[dt_pass][0]; | |
| 4040 | ✗ | data[8] = DoorComboSets[dcs].doorcombo_u[dt_pass][1]; | |
| 4041 | ✗ | cset[8] = DoorComboSets[dcs].doorcset_u[dt_pass][1]; | |
| 4042 | ✗ | data[23] = DoorComboSets[dcs].doorcombo_u[dt_pass][2]; | |
| 4043 | ✗ | cset[23] = DoorComboSets[dcs].doorcset_u[dt_pass][2]; | |
| 4044 | ✗ | data[24] = DoorComboSets[dcs].doorcombo_u[dt_pass][3]; | |
| 4045 | ✗ | cset[24] = DoorComboSets[dcs].doorcset_u[dt_pass][3]; | |
| 4046 | ✗ | break; | |
| 4047 | } | ||
| 4048 | |||
| 4049 | ✗ | break; | |
| 4050 | |||
| 4051 | case down: | ||
| 4052 | ✗ | switch(door) | |
| 4053 | { | ||
| 4054 | case dWALL: | ||
| 4055 | case dBOMB: | ||
| 4056 | case dWALK: | ||
| 4057 | ✗ | data[151] = DoorComboSets[dcs].doorcombo_d[dt_wall][0]; | |
| 4058 | ✗ | cset[151] = DoorComboSets[dcs].doorcset_d[dt_wall][0]; | |
| 4059 | ✗ | data[152] = DoorComboSets[dcs].doorcombo_d[dt_wall][1]; | |
| 4060 | ✗ | cset[152] = DoorComboSets[dcs].doorcset_d[dt_wall][1]; | |
| 4061 | ✗ | data[167] = DoorComboSets[dcs].doorcombo_d[dt_wall][2]; | |
| 4062 | ✗ | cset[167] = DoorComboSets[dcs].doorcset_d[dt_wall][2]; | |
| 4063 | ✗ | data[168] = DoorComboSets[dcs].doorcombo_d[dt_wall][3]; | |
| 4064 | ✗ | cset[168] = DoorComboSets[dcs].doorcset_d[dt_wall][3]; | |
| 4065 | ✗ | break; | |
| 4066 | |||
| 4067 | default: | ||
| 4068 | ✗ | data[151] = DoorComboSets[dcs].doorcombo_d[dt_pass][0]; | |
| 4069 | ✗ | cset[151] = DoorComboSets[dcs].doorcset_d[dt_pass][0]; | |
| 4070 | ✗ | data[152] = DoorComboSets[dcs].doorcombo_d[dt_pass][1]; | |
| 4071 | ✗ | cset[152] = DoorComboSets[dcs].doorcset_d[dt_pass][1]; | |
| 4072 | ✗ | data[167] = DoorComboSets[dcs].doorcombo_d[dt_pass][2]; | |
| 4073 | ✗ | cset[167] = DoorComboSets[dcs].doorcset_d[dt_pass][2]; | |
| 4074 | ✗ | data[168] = DoorComboSets[dcs].doorcombo_d[dt_pass][3]; | |
| 4075 | ✗ | cset[168] = DoorComboSets[dcs].doorcset_d[dt_pass][3]; | |
| 4076 | ✗ | break; | |
| 4077 | } | ||
| 4078 | |||
| 4079 | ✗ | break; | |
| 4080 | |||
| 4081 | case left: | ||
| 4082 | ✗ | switch(door) | |
| 4083 | { | ||
| 4084 | case dWALL: | ||
| 4085 | case dBOMB: | ||
| 4086 | case dWALK: | ||
| 4087 | ✗ | data[64] = DoorComboSets[dcs].doorcombo_l[dt_wall][0]; | |
| 4088 | ✗ | cset[64] = DoorComboSets[dcs].doorcset_l[dt_wall][0]; | |
| 4089 | ✗ | data[65] = DoorComboSets[dcs].doorcombo_l[dt_wall][1]; | |
| 4090 | ✗ | cset[65] = DoorComboSets[dcs].doorcset_l[dt_wall][1]; | |
| 4091 | ✗ | data[80] = DoorComboSets[dcs].doorcombo_l[dt_wall][2]; | |
| 4092 | ✗ | cset[80] = DoorComboSets[dcs].doorcset_l[dt_wall][2]; | |
| 4093 | ✗ | data[81] = DoorComboSets[dcs].doorcombo_l[dt_wall][3]; | |
| 4094 | ✗ | cset[81] = DoorComboSets[dcs].doorcset_l[dt_wall][3]; | |
| 4095 | ✗ | data[96] = DoorComboSets[dcs].doorcombo_l[dt_wall][4]; | |
| 4096 | ✗ | cset[96] = DoorComboSets[dcs].doorcset_l[dt_wall][4]; | |
| 4097 | ✗ | data[97] = DoorComboSets[dcs].doorcombo_l[dt_wall][5]; | |
| 4098 | ✗ | cset[97] = DoorComboSets[dcs].doorcset_l[dt_wall][5]; | |
| 4099 | ✗ | break; | |
| 4100 | |||
| 4101 | default: | ||
| 4102 | ✗ | data[64] = DoorComboSets[dcs].doorcombo_l[dt_pass][0]; | |
| 4103 | ✗ | cset[64] = DoorComboSets[dcs].doorcset_l[dt_pass][0]; | |
| 4104 | ✗ | data[65] = DoorComboSets[dcs].doorcombo_l[dt_pass][1]; | |
| 4105 | ✗ | cset[65] = DoorComboSets[dcs].doorcset_l[dt_pass][1]; | |
| 4106 | ✗ | data[80] = DoorComboSets[dcs].doorcombo_l[dt_pass][2]; | |
| 4107 | ✗ | cset[80] = DoorComboSets[dcs].doorcset_l[dt_pass][2]; | |
| 4108 | ✗ | data[81] = DoorComboSets[dcs].doorcombo_l[dt_pass][3]; | |
| 4109 | ✗ | cset[81] = DoorComboSets[dcs].doorcset_l[dt_pass][3]; | |
| 4110 | ✗ | data[96] = DoorComboSets[dcs].doorcombo_l[dt_pass][4]; | |
| 4111 | ✗ | cset[96] = DoorComboSets[dcs].doorcset_l[dt_pass][4]; | |
| 4112 | ✗ | data[97] = DoorComboSets[dcs].doorcombo_l[dt_pass][5]; | |
| 4113 | ✗ | cset[97] = DoorComboSets[dcs].doorcset_l[dt_pass][5]; | |
| 4114 | ✗ | break; | |
| 4115 | } | ||
| 4116 | |||
| 4117 | ✗ | break; | |
| 4118 | |||
| 4119 | case right: | ||
| 4120 | ✗ | switch(door) | |
| 4121 | { | ||
| 4122 | case dWALL: | ||
| 4123 | case dBOMB: | ||
| 4124 | case dWALK: | ||
| 4125 | ✗ | data[78] = DoorComboSets[dcs].doorcombo_r[dt_wall][0]; | |
| 4126 | ✗ | cset[78] = DoorComboSets[dcs].doorcset_r[dt_wall][0]; | |
| 4127 | ✗ | data[79] = DoorComboSets[dcs].doorcombo_r[dt_wall][1]; | |
| 4128 | ✗ | cset[79] = DoorComboSets[dcs].doorcset_r[dt_wall][1]; | |
| 4129 | ✗ | data[94] = DoorComboSets[dcs].doorcombo_r[dt_wall][2]; | |
| 4130 | ✗ | cset[94] = DoorComboSets[dcs].doorcset_r[dt_wall][2]; | |
| 4131 | ✗ | data[95] = DoorComboSets[dcs].doorcombo_r[dt_wall][3]; | |
| 4132 | ✗ | cset[95] = DoorComboSets[dcs].doorcset_r[dt_wall][3]; | |
| 4133 | ✗ | data[110] = DoorComboSets[dcs].doorcombo_r[dt_wall][4]; | |
| 4134 | ✗ | cset[110] = DoorComboSets[dcs].doorcset_r[dt_wall][4]; | |
| 4135 | ✗ | data[111] = DoorComboSets[dcs].doorcombo_r[dt_wall][5]; | |
| 4136 | ✗ | cset[111] = DoorComboSets[dcs].doorcset_r[dt_wall][5]; | |
| 4137 | ✗ | break; | |
| 4138 | |||
| 4139 | default: | ||
| 4140 | ✗ | data[78] = DoorComboSets[dcs].doorcombo_r[dt_pass][0]; | |
| 4141 | ✗ | cset[78] = DoorComboSets[dcs].doorcset_r[dt_pass][0]; | |
| 4142 | ✗ | data[79] = DoorComboSets[dcs].doorcombo_r[dt_pass][1]; | |
| 4143 | ✗ | cset[79] = DoorComboSets[dcs].doorcset_r[dt_pass][1]; | |
| 4144 | ✗ | data[94] = DoorComboSets[dcs].doorcombo_r[dt_pass][2]; | |
| 4145 | ✗ | cset[94] = DoorComboSets[dcs].doorcset_r[dt_pass][2]; | |
| 4146 | ✗ | data[95] = DoorComboSets[dcs].doorcombo_r[dt_pass][3]; | |
| 4147 | ✗ | cset[95] = DoorComboSets[dcs].doorcset_r[dt_pass][3]; | |
| 4148 | ✗ | data[110] = DoorComboSets[dcs].doorcombo_r[dt_pass][4]; | |
| 4149 | ✗ | cset[110] = DoorComboSets[dcs].doorcset_r[dt_pass][4]; | |
| 4150 | ✗ | data[111] = DoorComboSets[dcs].doorcombo_r[dt_pass][5]; | |
| 4151 | ✗ | cset[111] = DoorComboSets[dcs].doorcset_r[dt_pass][5]; | |
| 4152 | ✗ | break; | |
| 4153 | } | ||
| 4154 | |||
| 4155 | ✗ | break; | |
| 4156 | } | ||
| 4157 | ✗ | } | |
| 4158 | ✗ | void zmap::DoPutDoorCommand(int side, int door, bool force) | |
| 4159 | { | ||
| 4160 | ✗ | if(!force && screens[cursor.screen].door[side] == door) | |
| 4161 | ✗ | return; | |
| 4162 | ✗ | bool already_list = InListCommand(); | |
| 4163 | ✗ | if(!already_list) | |
| 4164 | ✗ | StartListCommand(); | |
| 4165 | ✗ | DoSetDoorCommand(cursor.screen,side,door); | |
| 4166 | ✗ | if(door != dNONE) | |
| 4167 | { | ||
| 4168 | ✗ | word data[176] = {0}; | |
| 4169 | ✗ | byte cset[176] = {0}; | |
| 4170 | ✗ | fetch_door(side, door, screens[cursor.screen].door_combo_set, data, cset); | |
| 4171 | ✗ | for(int q = 0; q < 176; ++q) | |
| 4172 | ✗ | if(data[q]) | |
| 4173 | ✗ | DoSetComboCommand(cursor.map,cursor.screen,q,data[q],cset[q]); | |
| 4174 | ✗ | } | |
| 4175 | ✗ | if(!already_list) | |
| 4176 | ✗ | FinishListCommand(); | |
| 4177 | ✗ | } | |
| 4178 | ✗ | void zmap::putdoor(int32_t screen,int32_t side,int32_t door) | |
| 4179 | { | ||
| 4180 | ✗ | if(screens[screen].door[side] == door) | |
| 4181 | ✗ | return; | |
| 4182 | |||
| 4183 | ✗ | screens[screen].door[side] = door; | |
| 4184 | ✗ | if(door != dNONE) | |
| 4185 | { | ||
| 4186 | ✗ | word data[176] = {0}; | |
| 4187 | ✗ | byte cset[176] = {0}; | |
| 4188 | ✗ | fetch_door(side, door, screens[screen].door_combo_set, data, cset); | |
| 4189 | ✗ | for(int q = 0; q < 176; ++q) | |
| 4190 | ✗ | if(data[q]) | |
| 4191 | { | ||
| 4192 | ✗ | screens[screen].data[q] = data[q]; | |
| 4193 | ✗ | screens[screen].cset[q] = cset[q]; | |
| 4194 | ✗ | } | |
| 4195 | ✗ | } | |
| 4196 | ✗ | } | |
| 4197 | |||
| 4198 | ✗ | void list_command::execute() | |
| 4199 | { | ||
| 4200 | ✗ | for (auto command : commands) | |
| 4201 | { | ||
| 4202 | ✗ | command->execute(); | |
| 4203 | ✗ | } | |
| 4204 | ✗ | } | |
| 4205 | |||
| 4206 | ✗ | void list_command::undo() | |
| 4207 | { | ||
| 4208 | ✗ | for (int i = commands.size() - 1; i >= 0; i--) | |
| 4209 | { | ||
| 4210 | ✗ | commands[i]->undo(); | |
| 4211 | ✗ | } | |
| 4212 | ✗ | } | |
| 4213 | |||
| 4214 | ✗ | int list_command::size() | |
| 4215 | { | ||
| 4216 | ✗ | int s = 0; | |
| 4217 | ✗ | for (auto command : commands) | |
| 4218 | { | ||
| 4219 | ✗ | s += command->size(); | |
| 4220 | ✗ | } | |
| 4221 | ✗ | return s; | |
| 4222 | ✗ | } | |
| 4223 | |||
| 4224 | ✗ | void set_combo_command::execute() | |
| 4225 | { | ||
| 4226 | ✗ | mapscr* scr_ptr = Map.AbsoluteScrMakeValid(map, scr); | |
| 4227 | ✗ | if (!scr_ptr) return; | |
| 4228 | |||
| 4229 | ✗ | if (combo != -1) scr_ptr->data[pos] = combo; | |
| 4230 | ✗ | scr_ptr->cset[pos] = cset; | |
| 4231 | ✗ | } | |
| 4232 | |||
| 4233 | ✗ | void set_combo_command::undo() | |
| 4234 | { | ||
| 4235 | ✗ | mapscr* mapscr_ptr = Map.AbsoluteScr(map, scr); | |
| 4236 | ✗ | if(!mapscr_ptr) return; | |
| 4237 | ✗ | if (combo != -1) mapscr_ptr->data[pos] = prev_combo; | |
| 4238 | ✗ | mapscr_ptr->cset[pos] = prev_cset; | |
| 4239 | ✗ | } | |
| 4240 | |||
| 4241 | ✗ | set_ffc_command::data_t set_ffc_command::create_data(const ffcdata& ffc) | |
| 4242 | { | ||
| 4243 | std::array<int, 8> initd_arr; | ||
| 4244 | ✗ | std::copy(std::begin(ffc.initd), std::end(ffc.initd), initd_arr.begin()); | |
| 4245 | |||
| 4246 | ✗ | return { | |
| 4247 | ✗ | .x = ffc.x, | |
| 4248 | ✗ | .y = ffc.y, | |
| 4249 | ✗ | .vx = ffc.vx, | |
| 4250 | ✗ | .vy = ffc.vy, | |
| 4251 | ✗ | .ax = ffc.ax, | |
| 4252 | ✗ | .ay = ffc.ay, | |
| 4253 | ✗ | .data = ffc.data, | |
| 4254 | ✗ | .cset = ffc.cset, | |
| 4255 | ✗ | .delay = ffc.delay, | |
| 4256 | ✗ | .link = ffc.link, | |
| 4257 | ✗ | .script = ffc.script, | |
| 4258 | ✗ | .tw = ffc.txsz, | |
| 4259 | ✗ | .th = ffc.tysz, | |
| 4260 | ✗ | .ew = ffc.hit_width, | |
| 4261 | ✗ | .eh = ffc.hit_height, | |
| 4262 | ✗ | .flags = ffc.flags, | |
| 4263 | ✗ | .initd = initd_arr, | |
| 4264 | ✗ | .layer = ffc.layer | |
| 4265 | }; | ||
| 4266 | } | ||
| 4267 | |||
| 4268 | ✗ | void set_ffc_command::execute() | |
| 4269 | { | ||
| 4270 | ✗ | mapscr* mapscr_ptr = Map.AbsoluteScrMakeValid(map, scr); | |
| 4271 | ✗ | if(!mapscr_ptr) return; | |
| 4272 | |||
| 4273 | ✗ | mapscr_ptr->valid |= mVALID; | |
| 4274 | ✗ | mapscr_ptr->ffcs[i].x = data.x; | |
| 4275 | ✗ | mapscr_ptr->ffcs[i].y = data.y; | |
| 4276 | ✗ | mapscr_ptr->ffcs[i].vx = data.vx; | |
| 4277 | ✗ | mapscr_ptr->ffcs[i].vy = data.vy; | |
| 4278 | ✗ | mapscr_ptr->ffcs[i].ax = data.ax; | |
| 4279 | ✗ | mapscr_ptr->ffcs[i].ay = data.ay; | |
| 4280 | ✗ | mapscr_ptr->ffcs[i].data = data.data; | |
| 4281 | ✗ | mapscr_ptr->ffcs[i].cset = data.cset; | |
| 4282 | ✗ | mapscr_ptr->ffcs[i].delay = data.delay; | |
| 4283 | ✗ | mapscr_ptr->ffcs[i].link = data.link; | |
| 4284 | ✗ | mapscr_ptr->ffcs[i].script = data.script; | |
| 4285 | ✗ | mapscr_ptr->ffcs[i].flags = data.flags; | |
| 4286 | ✗ | mapscr_ptr->ffEffectWidth(i, data.ew); | |
| 4287 | ✗ | mapscr_ptr->ffEffectHeight(i, data.eh); | |
| 4288 | ✗ | mapscr_ptr->ffTileWidth(i, data.tw); | |
| 4289 | ✗ | mapscr_ptr->ffTileHeight(i, data.th); | |
| 4290 | ✗ | std::copy(std::begin(data.initd), std::end(data.initd), std::begin(mapscr_ptr->ffcs[i].initd)); | |
| 4291 | ✗ | mapscr_ptr->ffcs[i].layer = data.layer; | |
| 4292 | ✗ | mapscr_ptr->ffcCountMarkDirty(); | |
| 4293 | ✗ | mapscr_ptr->ffcs[i].updateSolid(); | |
| 4294 | ✗ | } | |
| 4295 | |||
| 4296 | ✗ | void set_ffc_command::undo() | |
| 4297 | { | ||
| 4298 | ✗ | mapscr* mapscr_ptr = Map.AbsoluteScr(map, scr); | |
| 4299 | ✗ | if(!mapscr_ptr) return; | |
| 4300 | |||
| 4301 | ✗ | mapscr_ptr->ffcs[i].x = prev_data.x; | |
| 4302 | ✗ | mapscr_ptr->ffcs[i].y = prev_data.y; | |
| 4303 | ✗ | mapscr_ptr->ffcs[i].vx = prev_data.vx; | |
| 4304 | ✗ | mapscr_ptr->ffcs[i].vy = prev_data.vy; | |
| 4305 | ✗ | mapscr_ptr->ffcs[i].ax = prev_data.ax; | |
| 4306 | ✗ | mapscr_ptr->ffcs[i].ay = prev_data.ay; | |
| 4307 | ✗ | mapscr_ptr->ffcs[i].data = prev_data.data; | |
| 4308 | ✗ | mapscr_ptr->ffcs[i].cset = prev_data.cset; | |
| 4309 | ✗ | mapscr_ptr->ffcs[i].delay = prev_data.delay; | |
| 4310 | ✗ | mapscr_ptr->ffcs[i].link = prev_data.link; | |
| 4311 | ✗ | mapscr_ptr->ffcs[i].script = prev_data.script; | |
| 4312 | ✗ | mapscr_ptr->ffcs[i].flags = prev_data.flags; | |
| 4313 | ✗ | mapscr_ptr->ffEffectWidth(i, prev_data.ew); | |
| 4314 | ✗ | mapscr_ptr->ffEffectHeight(i, prev_data.eh); | |
| 4315 | ✗ | mapscr_ptr->ffTileWidth(i, prev_data.tw); | |
| 4316 | ✗ | mapscr_ptr->ffTileHeight(i, prev_data.th); | |
| 4317 | ✗ | std::copy(std::begin(prev_data.initd), std::end(prev_data.initd), std::begin(mapscr_ptr->ffcs[i].initd)); | |
| 4318 | ✗ | mapscr_ptr->ffcs[i].layer = prev_data.layer; | |
| 4319 | ✗ | mapscr_ptr->ffcCountMarkDirty(); | |
| 4320 | ✗ | mapscr_ptr->ffcs[i].updateSolid(); | |
| 4321 | ✗ | } | |
| 4322 | |||
| 4323 | ✗ | void set_flag_command::execute() | |
| 4324 | { | ||
| 4325 | ✗ | mapscr* mapscr_ptr = Map.AbsoluteScrMakeValid(map, scr); | |
| 4326 | ✗ | if(!mapscr_ptr) return; | |
| 4327 | |||
| 4328 | ✗ | mapscr_ptr->valid |= mVALID; | |
| 4329 | ✗ | mapscr_ptr->sflag[pos] = flag; | |
| 4330 | ✗ | } | |
| 4331 | |||
| 4332 | ✗ | void set_flag_command::undo() | |
| 4333 | { | ||
| 4334 | ✗ | mapscr* mapscr_ptr = Map.AbsoluteScr(map, scr); | |
| 4335 | ✗ | if(!mapscr_ptr) return; | |
| 4336 | ✗ | mapscr_ptr->sflag[pos] = prev_flag; | |
| 4337 | ✗ | } | |
| 4338 | |||
| 4339 | ✗ | void set_door_command::execute() | |
| 4340 | { | ||
| 4341 | ✗ | auto* mapscr_ptr = Map.AbsoluteScrMakeValid(cursor.map, cursor.screen); | |
| 4342 | ✗ | if(!mapscr_ptr) return; | |
| 4343 | |||
| 4344 | ✗ | mapscr_ptr->valid |= mVALID; | |
| 4345 | ✗ | mapscr_ptr->door[side] = door; | |
| 4346 | ✗ | } | |
| 4347 | |||
| 4348 | ✗ | void set_door_command::undo() | |
| 4349 | { | ||
| 4350 | ✗ | Map.AbsoluteScr(cursor.map, cursor.screen)->door[side] = prev_door; | |
| 4351 | ✗ | } | |
| 4352 | |||
| 4353 | ✗ | void set_dcs_command::execute() | |
| 4354 | { | ||
| 4355 | ✗ | auto* mapscr_ptr = Map.AbsoluteScrMakeValid(cursor.map, cursor.screen); | |
| 4356 | ✗ | if(!mapscr_ptr) return; | |
| 4357 | |||
| 4358 | ✗ | mapscr_ptr->valid |= mVALID; | |
| 4359 | ✗ | mapscr_ptr->door_combo_set = dcs; | |
| 4360 | ✗ | } | |
| 4361 | |||
| 4362 | ✗ | void set_dcs_command::undo() | |
| 4363 | { | ||
| 4364 | ✗ | Map.AbsoluteScr(cursor.map, cursor.screen)->door_combo_set = prev_dcs; | |
| 4365 | ✗ | } | |
| 4366 | |||
| 4367 | ✗ | void paste_screen_command::execute() | |
| 4368 | { | ||
| 4369 | ✗ | perform(screen.get()); | |
| 4370 | ✗ | } | |
| 4371 | |||
| 4372 | ✗ | void paste_screen_command::undo() | |
| 4373 | { | ||
| 4374 | ✗ | if (prev_screens.size() > 1) | |
| 4375 | { | ||
| 4376 | ASSERT(type == PasteCommandType::ScreenPartialToEveryScreen || type == PasteCommandType::ScreenAllToEveryScreen); | ||
| 4377 | ASSERT(prev_screens.size() == 128); | ||
| 4378 | ✗ | for (int i = 0; i < 128; i++) | |
| 4379 | { | ||
| 4380 | ✗ | copy_mapscr(Map.AbsoluteScrMakeValid(cursor.map, i), prev_screens[i].get()); | |
| 4381 | // TODO: why not just this? | ||
| 4382 | // If this changes, also change the line in PasteAllToAll and PasteAll to use simply copy assignment. | ||
| 4383 | // *Map.AbsoluteScr(map, i) = *prev_screens[i].get(); | ||
| 4384 | ✗ | } | |
| 4385 | ✗ | return; | |
| 4386 | } | ||
| 4387 | |||
| 4388 | ✗ | perform(prev_screens[0].get()); | |
| 4389 | ✗ | } | |
| 4390 | |||
| 4391 | ✗ | int paste_screen_command::size() | |
| 4392 | { | ||
| 4393 | ✗ | return prev_screens.size() + 1; | |
| 4394 | } | ||
| 4395 | |||
| 4396 | ✗ | void paste_screen_command::perform(mapscr* to) | |
| 4397 | { | ||
| 4398 | ✗ | if (to) | |
| 4399 | { | ||
| 4400 | ✗ | switch (type) { | |
| 4401 | ✗ | case ScreenAll: Map.PasteAll(*to, screen_index); break; | |
| 4402 | ✗ | case ScreenAllToEveryScreen: Map.PasteAllToAll(*to); break; | |
| 4403 | ✗ | case ScreenData: Map.PasteScreenData(*to, screen_index); break; | |
| 4404 | ✗ | case ScreenDoors: Map.PasteDoors(*to, screen_index); break; | |
| 4405 | ✗ | case ScreenEnemies: Map.PasteEnemies(*to, screen_index); break; | |
| 4406 | ✗ | case ScreenFFCombos: Map.PasteFFCombos(*to, screen_index); break; | |
| 4407 | ✗ | case ScreenGuy: Map.PasteGuy(*to, screen_index); break; | |
| 4408 | ✗ | case ScreenLayers: Map.PasteLayers(*to, screen_index); break; | |
| 4409 | ✗ | case ScreenPalette: Map.PastePalette(*to, screen_index); break; | |
| 4410 | ✗ | case ScreenPartial: Map.Paste(*to, screen_index); break; | |
| 4411 | ✗ | case ScreenPartialToEveryScreen: Map.PasteToAll(*to); break; | |
| 4412 | ✗ | case ScreenRoom: Map.PasteRoom(*to, screen_index); break; | |
| 4413 | ✗ | case ScreenSecretCombos: Map.PasteSecretCombos(*to, screen_index); break; | |
| 4414 | ✗ | case ScreenUnderCombo: Map.PasteUnderCombo(*to, screen_index); break; | |
| 4415 | ✗ | case ScreenWarpLocations: Map.PasteWarpLocations(*to, screen_index); break; | |
| 4416 | ✗ | case ScreenWarps: Map.PasteWarps(*to, screen_index); break; | |
| 4417 | } | ||
| 4418 | ✗ | } | |
| 4419 | else | ||
| 4420 | { | ||
| 4421 | ✗ | Map.clearscr(screen_index); | |
| 4422 | } | ||
| 4423 | ✗ | refresh(rALL); | |
| 4424 | ✗ | } | |
| 4425 | |||
| 4426 | ✗ | void set_screen_command::execute() | |
| 4427 | { | ||
| 4428 | ✗ | if (screen) | |
| 4429 | { | ||
| 4430 | ✗ | copy_mapscr(Map.AbsoluteScrMakeValid(cursor.map, screen_index), screen.get()); | |
| 4431 | ✗ | } | |
| 4432 | else | ||
| 4433 | { | ||
| 4434 | ✗ | Map.clearscr(screen_index); | |
| 4435 | } | ||
| 4436 | ✗ | refresh(rALL); | |
| 4437 | ✗ | } | |
| 4438 | |||
| 4439 | ✗ | void set_screen_command::undo() | |
| 4440 | { | ||
| 4441 | ✗ | if (prev_screen) | |
| 4442 | { | ||
| 4443 | ✗ | copy_mapscr(Map.AbsoluteScrMakeValid(cursor.map, screen_index), prev_screen.get()); | |
| 4444 | ✗ | } | |
| 4445 | else | ||
| 4446 | { | ||
| 4447 | ✗ | Map.clearscr(screen_index); | |
| 4448 | } | ||
| 4449 | ✗ | refresh(rALL); | |
| 4450 | ✗ | } | |
| 4451 | |||
| 4452 | ✗ | int set_screen_command::size() | |
| 4453 | { | ||
| 4454 | ✗ | return (prev_screen ? 1 : 0) + (screen ? 1 : 0); | |
| 4455 | } | ||
| 4456 | |||
| 4457 | static std::shared_ptr<list_command> current_list_command; | ||
| 4458 | ✗ | void zmap::StartListCommand() | |
| 4459 | { | ||
| 4460 | ASSERT(!current_list_command); | ||
| 4461 | ✗ | current_list_command.reset(new list_command); | |
| 4462 | ✗ | } | |
| 4463 | |||
| 4464 | ✗ | void zmap::FinishListCommand() | |
| 4465 | { | ||
| 4466 | ✗ | if (current_list_command->commands.size() == 1) | |
| 4467 | { | ||
| 4468 | ✗ | undo_stack.push_back(current_list_command->commands[0]); | |
| 4469 | ✗ | } | |
| 4470 | ✗ | else if (current_list_command->commands.size() > 1) | |
| 4471 | { | ||
| 4472 | ✗ | undo_stack.push_back(current_list_command); | |
| 4473 | ✗ | } | |
| 4474 | ✗ | CapCommandHistory(); | |
| 4475 | ✗ | current_list_command = nullptr; | |
| 4476 | ✗ | } | |
| 4477 | |||
| 4478 | ✗ | void zmap::RevokeListCommand() | |
| 4479 | { | ||
| 4480 | ✗ | current_list_command->undo(); | |
| 4481 | ✗ | current_list_command = nullptr; | |
| 4482 | ✗ | } | |
| 4483 | |||
| 4484 | ✗ | bool zmap::InListCommand() const | |
| 4485 | { | ||
| 4486 | ✗ | return current_list_command ? true : false; | |
| 4487 | } | ||
| 4488 | |||
| 4489 | ✗ | void zmap::ExecuteCommand(std::shared_ptr<user_input_command> command, bool skip_execute) | |
| 4490 | { | ||
| 4491 | ✗ | redo_stack = std::stack<std::shared_ptr<user_input_command>>(); | |
| 4492 | ✗ | if (!skip_execute) command->execute(); | |
| 4493 | ✗ | if (current_list_command) | |
| 4494 | { | ||
| 4495 | ✗ | current_list_command->commands.push_back(command); | |
| 4496 | ✗ | if (current_list_command->commands.size() == 1) | |
| 4497 | { | ||
| 4498 | ✗ | current_list_command->cursor = command->cursor; | |
| 4499 | ✗ | } | |
| 4500 | ✗ | } | |
| 4501 | else | ||
| 4502 | { | ||
| 4503 | ✗ | undo_stack.push_back(command); | |
| 4504 | ✗ | CapCommandHistory(); | |
| 4505 | } | ||
| 4506 | ✗ | saved = false; | |
| 4507 | ✗ | } | |
| 4508 | |||
| 4509 | ✗ | void zmap::UndoCommand() | |
| 4510 | { | ||
| 4511 | ✗ | if (undo_stack.size() <= 0) return; | |
| 4512 | |||
| 4513 | // If not currently looking at the associated screen, first change the view | ||
| 4514 | // and wait for the next call to actually undo this command. | ||
| 4515 | ✗ | auto command = undo_stack.back(); | |
| 4516 | ✗ | if (command->cursor.map != Map.getCurrMap() || command->cursor.screen != Map.getCurrScr()) | |
| 4517 | { | ||
| 4518 | ✗ | setCursor(command.get()->cursor); | |
| 4519 | ✗ | return; | |
| 4520 | } | ||
| 4521 | |||
| 4522 | ✗ | command->undo(); | |
| 4523 | ✗ | redo_stack.push(command); | |
| 4524 | ✗ | undo_stack.pop_back(); | |
| 4525 | ✗ | saved = false; | |
| 4526 | ✗ | } | |
| 4527 | |||
| 4528 | ✗ | void zmap::RedoCommand() | |
| 4529 | { | ||
| 4530 | ✗ | if (redo_stack.size() <= 0) return; | |
| 4531 | |||
| 4532 | // If not currently selected the associated screen, first change the cursor | ||
| 4533 | // and wait for the next call to actually execute this command. | ||
| 4534 | ✗ | auto command = redo_stack.top(); | |
| 4535 | ✗ | if (command->cursor.map != Map.getCurrMap() || command->cursor.screen != Map.getCurrScr()) | |
| 4536 | { | ||
| 4537 | ✗ | setCursor(command.get()->cursor); | |
| 4538 | ✗ | return; | |
| 4539 | } | ||
| 4540 | |||
| 4541 | ✗ | command->execute(); | |
| 4542 | ✗ | undo_stack.push_back(command); | |
| 4543 | ✗ | redo_stack.pop(); | |
| 4544 | ✗ | saved = false; | |
| 4545 | ✗ | } | |
| 4546 | |||
| 4547 | 11 | void zmap::ClearCommandHistory() | |
| 4548 | { | ||
| 4549 | 11 | current_list_command = nullptr; | |
| 4550 | 11 | undo_stack = std::deque<std::shared_ptr<user_input_command>>(); | |
| 4551 | 11 | redo_stack = std::stack<std::shared_ptr<user_input_command>>(); | |
| 4552 | 11 | } | |
| 4553 | |||
| 4554 | // Extra amount is from mapscr's vectors. | ||
| 4555 | static int size_of_mapscr = sizeof(mapscr) + 4*176; | ||
| 4556 | // Allow the undo system to use roughly 100 MB of memory. | ||
| 4557 | // This doesn't count the memory used by commands that don't store a mapscr, | ||
| 4558 | // but that should be negligible. | ||
| 4559 | 12 | static int max_command_size = 100e6 / size_of_mapscr; | |
| 4560 | ✗ | void zmap::CapCommandHistory() | |
| 4561 | { | ||
| 4562 | int size; | ||
| 4563 | ✗ | do | |
| 4564 | { | ||
| 4565 | ✗ | size = 0; | |
| 4566 | ✗ | for (auto command : undo_stack) | |
| 4567 | { | ||
| 4568 | ✗ | size += command->size(); | |
| 4569 | ✗ | } | |
| 4570 | ✗ | if (size > max_command_size) undo_stack.pop_front(); | |
| 4571 | ✗ | } while (size > max_command_size); | |
| 4572 | ✗ | } | |
| 4573 | |||
| 4574 | ✗ | void zmap::DoSetComboCommand(ComboPosition pos, int combo, int cset) | |
| 4575 | { | ||
| 4576 | ✗ | if (!pos.is_valid(cursor)) | |
| 4577 | ✗ | return; | |
| 4578 | |||
| 4579 | ✗ | int map = cursor.map; | |
| 4580 | ✗ | int screen = cursor.viewscr + pos.screen_offset(); | |
| 4581 | ✗ | if (!AbsoluteScr(map, screen)) | |
| 4582 | ✗ | return; | |
| 4583 | |||
| 4584 | ✗ | if (CurrentLayer) | |
| 4585 | { | ||
| 4586 | ✗ | mapscr* scr = AbsoluteScrMakeValid(map, screen); | |
| 4587 | ✗ | map = scr->layermap[CurrentLayer-1]-1; | |
| 4588 | ✗ | screen = scr->layerscreen[CurrentLayer-1]; | |
| 4589 | ✗ | } | |
| 4590 | ✗ | DoSetComboCommand(map, screen, pos.truncate(), combo, cset); | |
| 4591 | ✗ | } | |
| 4592 | |||
| 4593 | ✗ | void zmap::DoSetComboCommand(int map, int scr, int pos, int combo, int cset) | |
| 4594 | { | ||
| 4595 | ✗ | mapscr* mapscr_ptr = AbsoluteScrMakeValid(map, scr); | |
| 4596 | ✗ | if (!mapscr_ptr) return; | |
| 4597 | |||
| 4598 | ✗ | std::shared_ptr<set_combo_command> command(new set_combo_command); | |
| 4599 | ✗ | command->cursor = cursor; | |
| 4600 | ✗ | command->map = map; | |
| 4601 | ✗ | command->scr = scr; | |
| 4602 | ✗ | command->pos = pos; | |
| 4603 | ✗ | command->combo = combo; | |
| 4604 | ✗ | command->cset = cset; | |
| 4605 | ✗ | command->prev_combo = mapscr_ptr->data[pos]; | |
| 4606 | ✗ | command->prev_cset = mapscr_ptr->cset[pos]; | |
| 4607 | ✗ | if ((command->combo != -1 && command->prev_combo == command->combo) && command->cset == command->prev_cset) | |
| 4608 | { | ||
| 4609 | // nothing to do... | ||
| 4610 | ✗ | return; | |
| 4611 | } | ||
| 4612 | |||
| 4613 | ✗ | ExecuteCommand(command); | |
| 4614 | ✗ | } | |
| 4615 | |||
| 4616 | ✗ | void zmap::DoSetFFCCommand(int map, int scr, int i, set_ffc_command::data_t data) | |
| 4617 | { | ||
| 4618 | ✗ | mapscr* mapscr_ptr = Map.AbsoluteScr(map, scr); | |
| 4619 | ✗ | if(!mapscr_ptr) return; | |
| 4620 | |||
| 4621 | ✗ | mapscr_ptr->ensureFFC(i); | |
| 4622 | |||
| 4623 | ✗ | std::shared_ptr<set_ffc_command> command(new set_ffc_command); | |
| 4624 | |||
| 4625 | std::array<int, 8> initd_arr; | ||
| 4626 | ✗ | std::copy(std::begin(mapscr_ptr->ffcs[i].initd), std::end(mapscr_ptr->ffcs[i].initd), initd_arr.begin()); | |
| 4627 | |||
| 4628 | ✗ | auto prev_data = set_ffc_command::create_data(mapscr_ptr->ffcs[i]); | |
| 4629 | |||
| 4630 | ✗ | command->cursor = cursor; | |
| 4631 | ✗ | command->map = map; | |
| 4632 | ✗ | command->scr = scr; | |
| 4633 | ✗ | command->i = i; | |
| 4634 | ✗ | command->data = data; | |
| 4635 | ✗ | command->prev_data = prev_data; | |
| 4636 | ✗ | if (data == prev_data) | |
| 4637 | { | ||
| 4638 | // nothing to do... | ||
| 4639 | ✗ | return; | |
| 4640 | } | ||
| 4641 | |||
| 4642 | ✗ | ExecuteCommand(command); | |
| 4643 | ✗ | } | |
| 4644 | |||
| 4645 | ✗ | void zmap::DoSetFlagCommand(ComboPosition pos, int flag) | |
| 4646 | { | ||
| 4647 | ✗ | if (!pos.is_valid(cursor)) | |
| 4648 | ✗ | return; | |
| 4649 | |||
| 4650 | ✗ | int map = cursor.map; | |
| 4651 | ✗ | int screen = cursor.viewscr + pos.screen_offset(); | |
| 4652 | ✗ | if (!AbsoluteScr(map, screen)) | |
| 4653 | ✗ | return; | |
| 4654 | |||
| 4655 | ✗ | if (CurrentLayer) | |
| 4656 | { | ||
| 4657 | ✗ | mapscr* scr = AbsoluteScrMakeValid(map, screen); | |
| 4658 | ✗ | map = scr->layermap[CurrentLayer-1]-1; | |
| 4659 | ✗ | screen = scr->layerscreen[CurrentLayer-1]; | |
| 4660 | ✗ | } | |
| 4661 | ✗ | DoSetFlagCommand(map, screen, pos.truncate(), flag); | |
| 4662 | ✗ | } | |
| 4663 | |||
| 4664 | ✗ | void zmap::DoSetFlagCommand(int map, int scr, int pos, int flag) | |
| 4665 | { | ||
| 4666 | ✗ | mapscr* mapscr_ptr = Map.AbsoluteScr(map, scr); | |
| 4667 | ✗ | if(!mapscr_ptr) return; | |
| 4668 | |||
| 4669 | ✗ | std::shared_ptr<set_flag_command> command(new set_flag_command); | |
| 4670 | ✗ | command->cursor = cursor; | |
| 4671 | ✗ | command->map = map; | |
| 4672 | ✗ | command->scr = scr; | |
| 4673 | ✗ | command->pos = pos; | |
| 4674 | ✗ | command->flag = flag; | |
| 4675 | ✗ | command->prev_flag = mapscr_ptr->sflag[pos]; | |
| 4676 | ✗ | if (command->flag == command->prev_flag) | |
| 4677 | { | ||
| 4678 | // nothing to do... | ||
| 4679 | ✗ | return; | |
| 4680 | } | ||
| 4681 | |||
| 4682 | ✗ | ExecuteCommand(command); | |
| 4683 | ✗ | } | |
| 4684 | |||
| 4685 | ✗ | void zmap::DoSetDoorCommand(int scr, int side, int door) | |
| 4686 | { | ||
| 4687 | ✗ | if(screens[scr].door[side] == door) | |
| 4688 | ✗ | return; | |
| 4689 | ✗ | std::shared_ptr<set_door_command> command(new set_door_command); | |
| 4690 | ✗ | command->cursor = cursor; | |
| 4691 | ✗ | command->side = side; | |
| 4692 | ✗ | command->door = door; | |
| 4693 | ✗ | command->prev_door = screens[scr].door[side]; | |
| 4694 | |||
| 4695 | ✗ | ExecuteCommand(command); | |
| 4696 | ✗ | } | |
| 4697 | ✗ | void zmap::DoSetDCSCommand(int dcs) | |
| 4698 | { | ||
| 4699 | ✗ | if(screens[cursor.screen].door_combo_set == dcs) | |
| 4700 | ✗ | return; | |
| 4701 | ✗ | std::shared_ptr<set_dcs_command> command(new set_dcs_command); | |
| 4702 | ✗ | command->cursor = cursor; | |
| 4703 | ✗ | command->dcs = dcs; | |
| 4704 | ✗ | command->prev_dcs = screens[cursor.screen].door_combo_set; | |
| 4705 | |||
| 4706 | ✗ | ExecuteCommand(command); | |
| 4707 | ✗ | } | |
| 4708 | |||
| 4709 | ✗ | void zmap::DoPasteScreenCommand(PasteCommandType type, int screen) | |
| 4710 | { | ||
| 4711 | ✗ | if (screen == -1) | |
| 4712 | ✗ | screen = cursor.screen; | |
| 4713 | |||
| 4714 | ✗ | std::shared_ptr<paste_screen_command> command(new paste_screen_command); | |
| 4715 | ✗ | command->cursor = cursor; | |
| 4716 | ✗ | command->type = type; | |
| 4717 | ✗ | command->screen = std::shared_ptr<mapscr>(new mapscr(copymapscr)); | |
| 4718 | ✗ | command->screen_index = screen; | |
| 4719 | |||
| 4720 | ✗ | if (type == PasteCommandType::ScreenPartialToEveryScreen || type == PasteCommandType::ScreenAllToEveryScreen) | |
| 4721 | { | ||
| 4722 | ✗ | for (int i=0; i < 128; i++) | |
| 4723 | { | ||
| 4724 | ✗ | command->prev_screens.push_back(std::shared_ptr<mapscr>(new mapscr(screens[i]))); | |
| 4725 | ✗ | } | |
| 4726 | ✗ | } | |
| 4727 | else | ||
| 4728 | { | ||
| 4729 | ✗ | command->prev_screens.push_back(std::shared_ptr<mapscr>(new mapscr(screens[screen]))); | |
| 4730 | } | ||
| 4731 | |||
| 4732 | ✗ | ExecuteCommand(command); | |
| 4733 | ✗ | } | |
| 4734 | |||
| 4735 | ✗ | void zmap::DoClearScreenCommand(int screen) | |
| 4736 | { | ||
| 4737 | ✗ | std::shared_ptr<set_screen_command> command(new set_screen_command); | |
| 4738 | ✗ | command->cursor = cursor; | |
| 4739 | ✗ | command->prev_screen = std::shared_ptr<mapscr>(new mapscr(screens[screen])); | |
| 4740 | ✗ | command->screen = std::shared_ptr<mapscr>(nullptr); | |
| 4741 | ✗ | command->screen_index = screen; | |
| 4742 | |||
| 4743 | ✗ | ExecuteCommand(command); | |
| 4744 | ✗ | } | |
| 4745 | |||
| 4746 | ✗ | void zmap::DoTemplateCommand(int floorcombo, int floorcset, int screen) | |
| 4747 | { | ||
| 4748 | ✗ | std::shared_ptr<set_screen_command> command(new set_screen_command); | |
| 4749 | ✗ | command->cursor = cursor; | |
| 4750 | ✗ | command->prev_screen = std::shared_ptr<mapscr>(new mapscr(*Map.Scr(screen))); | |
| 4751 | ✗ | Template(floorcombo, floorcset, screen); | |
| 4752 | ✗ | command->screen = std::shared_ptr<mapscr>(new mapscr(*Map.Scr(screen))); | |
| 4753 | |||
| 4754 | ✗ | ExecuteCommand(command, true); | |
| 4755 | ✗ | } | |
| 4756 | |||
| 4757 | ✗ | void zmap::Copy(int scr) | |
| 4758 | { | ||
| 4759 | ✗ | if(screens[scr].valid&mVALID) | |
| 4760 | { | ||
| 4761 | ✗ | copy_mapscr(©mapscr, &screens[scr]); | |
| 4762 | //copymapscr=screens[scr]; | ||
| 4763 | ✗ | can_paste=true; | |
| 4764 | ✗ | copymap=cursor.map; | |
| 4765 | ✗ | copyscr=scr; | |
| 4766 | ✗ | copyscrdata = zinit.screen_data[cursor.map*MAPSCRS+scr]; | |
| 4767 | ✗ | copyffc = -1; | |
| 4768 | ✗ | } | |
| 4769 | ✗ | } | |
| 4770 | |||
| 4771 | ✗ | void zmap::CopyFFC(int32_t screen, int32_t n) | |
| 4772 | { | ||
| 4773 | ✗ | if(screens[screen].valid&mVALID) | |
| 4774 | { | ||
| 4775 | ✗ | copy_mapscr(©mapscr, &screens[screen]); | |
| 4776 | // Can't paste the screen itself | ||
| 4777 | ✗ | can_paste = false; | |
| 4778 | ✗ | copymap=cursor.map; | |
| 4779 | ✗ | copyscr=screen; | |
| 4780 | ✗ | copyffc = n; | |
| 4781 | ✗ | } | |
| 4782 | ✗ | } | |
| 4783 | |||
| 4784 | ✗ | void zmap::Paste(const mapscr& copymapscr, int screen) | |
| 4785 | { | ||
| 4786 | ✗ | if(can_paste) | |
| 4787 | { | ||
| 4788 | ✗ | int32_t oldcolor=getcolor(); | |
| 4789 | |||
| 4790 | ✗ | if(!(screens[screen].valid&mVALID)) | |
| 4791 | { | ||
| 4792 | ✗ | screens[screen].valid |= mVALID; | |
| 4793 | ✗ | screens[screen].color = copymapscr.color; | |
| 4794 | ✗ | } | |
| 4795 | |||
| 4796 | ✗ | screens[screen].door_combo_set = copymapscr.door_combo_set; | |
| 4797 | |||
| 4798 | ✗ | for(int32_t i=0; i<4; i++) | |
| 4799 | { | ||
| 4800 | ✗ | screens[screen].door[i]=copymapscr.door[i]; | |
| 4801 | ✗ | } | |
| 4802 | |||
| 4803 | ✗ | for(int32_t i=0; i<176; i++) | |
| 4804 | { | ||
| 4805 | ✗ | screens[screen].data[i] = copymapscr.data[i]; | |
| 4806 | ✗ | screens[screen].cset[i] = copymapscr.cset[i]; | |
| 4807 | ✗ | screens[screen].sflag[i] = copymapscr.sflag[i]; | |
| 4808 | ✗ | } | |
| 4809 | |||
| 4810 | ✗ | int32_t newcolor=getcolor(); | |
| 4811 | ✗ | loadlvlpal(newcolor); | |
| 4812 | |||
| 4813 | ✗ | if(newcolor!=oldcolor) | |
| 4814 | { | ||
| 4815 | ✗ | rebuild_trans_table(); | |
| 4816 | ✗ | } | |
| 4817 | |||
| 4818 | ✗ | saved=false; | |
| 4819 | ✗ | } | |
| 4820 | ✗ | } | |
| 4821 | |||
| 4822 | ✗ | void zmap::PasteUnderCombo(const mapscr& copymapscr, int screen) | |
| 4823 | { | ||
| 4824 | ✗ | if(can_paste) | |
| 4825 | { | ||
| 4826 | ✗ | screens[screen].undercombo = copymapscr.undercombo; | |
| 4827 | ✗ | screens[screen].undercset = copymapscr.undercset; | |
| 4828 | ✗ | saved=false; | |
| 4829 | ✗ | } | |
| 4830 | ✗ | } | |
| 4831 | |||
| 4832 | ✗ | void zmap::PasteSecretCombos(const mapscr& copymapscr, int screen) | |
| 4833 | { | ||
| 4834 | ✗ | if(can_paste) | |
| 4835 | { | ||
| 4836 | ✗ | for(int32_t i=0; i<128; i++) | |
| 4837 | { | ||
| 4838 | ✗ | screens[screen].secretcombo[i] = copymapscr.secretcombo[i]; | |
| 4839 | ✗ | screens[screen].secretcset[i] = copymapscr.secretcset[i]; | |
| 4840 | ✗ | screens[screen].secretflag[i] = copymapscr.secretflag[i]; | |
| 4841 | ✗ | } | |
| 4842 | |||
| 4843 | ✗ | saved=false; | |
| 4844 | ✗ | } | |
| 4845 | ✗ | } | |
| 4846 | |||
| 4847 | // TODO const mapscr& copymapscr | ||
| 4848 | ✗ | void zmap::PasteFFCombos(mapscr& copymapscr, int screen) | |
| 4849 | { | ||
| 4850 | ✗ | if(can_paste) | |
| 4851 | { | ||
| 4852 | ✗ | screens[screen].ffcs = copymapscr.ffcs; | |
| 4853 | ✗ | screens[screen].ffcCountMarkDirty(); | |
| 4854 | ✗ | saved=false; | |
| 4855 | ✗ | } | |
| 4856 | ✗ | } | |
| 4857 | |||
| 4858 | ✗ | void zmap::PasteWarps(const mapscr& copymapscr, int screen) | |
| 4859 | { | ||
| 4860 | ✗ | if(can_paste) | |
| 4861 | { | ||
| 4862 | ✗ | screens[screen].sidewarpindex = copymapscr.sidewarpindex; | |
| 4863 | |||
| 4864 | ✗ | for(int32_t i=0; i<4; i++) | |
| 4865 | { | ||
| 4866 | ✗ | screens[screen].tilewarptype[i] = copymapscr.tilewarptype[i]; | |
| 4867 | ✗ | screens[screen].tilewarpdmap[i] = copymapscr.tilewarpdmap[i]; | |
| 4868 | ✗ | screens[screen].tilewarpscr[i] = copymapscr.tilewarpscr[i]; | |
| 4869 | ✗ | screens[screen].sidewarptype[i] = copymapscr.sidewarptype[i]; | |
| 4870 | ✗ | screens[screen].sidewarpdmap[i] = copymapscr.sidewarpdmap[i]; | |
| 4871 | ✗ | screens[screen].sidewarpscr[i] = copymapscr.sidewarpscr[i]; | |
| 4872 | ✗ | screens[screen].flags2 &= ~(wfUP|wfDOWN|wfLEFT|wfRIGHT); | |
| 4873 | ✗ | screens[screen].flags2 |= copymapscr.flags2 & (wfUP|wfDOWN|wfLEFT|wfRIGHT); | |
| 4874 | ✗ | screens[screen].sidewarpoverlayflags = copymapscr.sidewarpoverlayflags; | |
| 4875 | ✗ | screens[screen].tilewarpoverlayflags = copymapscr.tilewarpoverlayflags; | |
| 4876 | ✗ | } | |
| 4877 | |||
| 4878 | ✗ | saved=false; | |
| 4879 | ✗ | } | |
| 4880 | ✗ | } | |
| 4881 | |||
| 4882 | ✗ | void zmap::PasteScreenData(const mapscr& copymapscr, int screen) | |
| 4883 | { | ||
| 4884 | ✗ | if(can_paste) | |
| 4885 | { | ||
| 4886 | ✗ | screens[screen].csensitive = copymapscr.csensitive; | |
| 4887 | ✗ | screens[screen].oceansfx = copymapscr.oceansfx; | |
| 4888 | ✗ | screens[screen].bosssfx = copymapscr.bosssfx; | |
| 4889 | ✗ | screens[screen].secretsfx = copymapscr.secretsfx; | |
| 4890 | ✗ | screens[screen].holdupsfx = copymapscr.holdupsfx; | |
| 4891 | ✗ | screens[screen].flags = copymapscr.flags; | |
| 4892 | ✗ | screens[screen].flags2 &= (wfUP|wfDOWN|wfLEFT|wfRIGHT); | |
| 4893 | ✗ | screens[screen].flags2 |= copymapscr.flags2 & ~(wfUP|wfDOWN|wfLEFT|wfRIGHT); | |
| 4894 | ✗ | screens[screen].flags3 = copymapscr.flags3; | |
| 4895 | ✗ | screens[screen].flags4 = copymapscr.flags4; | |
| 4896 | ✗ | screens[screen].flags5 = copymapscr.flags5; | |
| 4897 | ✗ | screens[screen].flags6 = copymapscr.flags6; | |
| 4898 | ✗ | screens[screen].flags7 = copymapscr.flags7; | |
| 4899 | ✗ | screens[screen].flags8 = copymapscr.flags8; | |
| 4900 | ✗ | screens[screen].flags9 = copymapscr.flags9; | |
| 4901 | ✗ | screens[screen].flags10 = copymapscr.flags10; | |
| 4902 | ✗ | screens[screen].flags11 = copymapscr.flags11; | |
| 4903 | ✗ | screens[screen].item = copymapscr.item; | |
| 4904 | ✗ | screens[screen].hasitem = copymapscr.hasitem; | |
| 4905 | ✗ | screens[screen].itemx = copymapscr.itemx; | |
| 4906 | ✗ | screens[screen].itemy = copymapscr.itemy; | |
| 4907 | ✗ | screens[screen].nextmap = copymapscr.nextmap; | |
| 4908 | ✗ | screens[screen].nextscr = copymapscr.nextscr; | |
| 4909 | ✗ | screens[screen].nocarry = copymapscr.nocarry; | |
| 4910 | ✗ | screens[screen].noreset = copymapscr.noreset; | |
| 4911 | ✗ | screens[screen].path[0] = copymapscr.path[0]; | |
| 4912 | ✗ | screens[screen].path[1] = copymapscr.path[1]; | |
| 4913 | ✗ | screens[screen].path[2] = copymapscr.path[2]; | |
| 4914 | ✗ | screens[screen].path[3] = copymapscr.path[3]; | |
| 4915 | ✗ | screens[screen].pattern = copymapscr.pattern; | |
| 4916 | ✗ | screens[screen].exitdir = copymapscr.exitdir; | |
| 4917 | ✗ | screens[screen].screen_midi = copymapscr.screen_midi; | |
| 4918 | ✗ | screens[screen].stairx = copymapscr.stairx; | |
| 4919 | ✗ | screens[screen].stairy = copymapscr.stairy; | |
| 4920 | ✗ | screens[screen].timedwarptics = copymapscr.timedwarptics; | |
| 4921 | ✗ | saved=false; | |
| 4922 | ✗ | } | |
| 4923 | ✗ | } | |
| 4924 | |||
| 4925 | ✗ | void zmap::PasteWarpLocations(const mapscr& copymapscr, int screen) | |
| 4926 | { | ||
| 4927 | ✗ | if(can_paste) | |
| 4928 | { | ||
| 4929 | ✗ | screens[screen].warpreturnc = copymapscr.warpreturnc; | |
| 4930 | ✗ | screens[screen].warparrivalx = copymapscr.warparrivalx; | |
| 4931 | ✗ | screens[screen].warparrivaly = copymapscr.warparrivaly; | |
| 4932 | |||
| 4933 | ✗ | for(int32_t i=0; i<4; i++) | |
| 4934 | { | ||
| 4935 | ✗ | screens[screen].warpreturnx[i] = copymapscr.warpreturnx[i]; | |
| 4936 | ✗ | screens[screen].warpreturny[i] = copymapscr.warpreturny[i]; | |
| 4937 | ✗ | } | |
| 4938 | |||
| 4939 | ✗ | saved=false; | |
| 4940 | ✗ | } | |
| 4941 | ✗ | } | |
| 4942 | |||
| 4943 | ✗ | void zmap::PasteDoors(const mapscr& copymapscr, int screen) | |
| 4944 | { | ||
| 4945 | ✗ | if(can_paste) | |
| 4946 | { | ||
| 4947 | ✗ | for(int32_t i=0; i<4; i++) | |
| 4948 | ✗ | screens[screen].door[i] = copymapscr.door[i]; | |
| 4949 | |||
| 4950 | ✗ | screens[screen].door_combo_set = copymapscr.door_combo_set; | |
| 4951 | ✗ | saved=false; | |
| 4952 | ✗ | } | |
| 4953 | ✗ | } | |
| 4954 | |||
| 4955 | ✗ | void zmap::PasteLayers(const mapscr& copymapscr, int screen) | |
| 4956 | { | ||
| 4957 | ✗ | if(can_paste) | |
| 4958 | { | ||
| 4959 | ✗ | for(int32_t i=0; i<6; i++) | |
| 4960 | { | ||
| 4961 | ✗ | screens[screen].layermap[i] = copymapscr.layermap[i]; | |
| 4962 | ✗ | screens[screen].layerscreen[i] = copymapscr.layerscreen[i]; | |
| 4963 | ✗ | screens[screen].layeropacity[i] = copymapscr.layeropacity[i]; | |
| 4964 | ✗ | } | |
| 4965 | |||
| 4966 | ✗ | saved=false; | |
| 4967 | ✗ | } | |
| 4968 | ✗ | } | |
| 4969 | |||
| 4970 | ✗ | void zmap::PasteRoom(const mapscr& copymapscr, int screen) | |
| 4971 | { | ||
| 4972 | ✗ | if(can_paste) | |
| 4973 | { | ||
| 4974 | ✗ | screens[screen].room = copymapscr.room; | |
| 4975 | ✗ | screens[screen].catchall = copymapscr.catchall; | |
| 4976 | ✗ | saved=false; | |
| 4977 | ✗ | } | |
| 4978 | ✗ | } | |
| 4979 | |||
| 4980 | ✗ | void zmap::PasteGuy(const mapscr& copymapscr, int screen) | |
| 4981 | { | ||
| 4982 | ✗ | if(can_paste) | |
| 4983 | { | ||
| 4984 | ✗ | screens[screen].guy = copymapscr.guy; | |
| 4985 | ✗ | screens[screen].guytile = copymapscr.guytile; | |
| 4986 | ✗ | screens[screen].guycs = copymapscr.guycs; | |
| 4987 | ✗ | SETFLAG(screens[screen].roomflags,RFL_ALWAYS_GUY,copymapscr.roomflags&RFL_ALWAYS_GUY); | |
| 4988 | ✗ | SETFLAG(screens[screen].roomflags,RFL_GUYFIRES,copymapscr.roomflags&RFL_GUYFIRES); | |
| 4989 | ✗ | screens[screen].str = copymapscr.str; | |
| 4990 | ✗ | saved=false; | |
| 4991 | ✗ | } | |
| 4992 | ✗ | } | |
| 4993 | |||
| 4994 | ✗ | void zmap::PastePalette(const mapscr& copymapscr, int screen) | |
| 4995 | { | ||
| 4996 | ✗ | if(can_paste) | |
| 4997 | { | ||
| 4998 | ✗ | int32_t oldcolor=getcolor(); | |
| 4999 | ✗ | screens[screen].color = copymapscr.color; | |
| 5000 | ✗ | int32_t newcolor=getcolor(); | |
| 5001 | ✗ | loadlvlpal(newcolor); | |
| 5002 | |||
| 5003 | ✗ | screens[screen].valid|=mVALID; | |
| 5004 | |||
| 5005 | ✗ | if(newcolor!=oldcolor) | |
| 5006 | { | ||
| 5007 | ✗ | rebuild_trans_table(); | |
| 5008 | ✗ | } | |
| 5009 | |||
| 5010 | ✗ | saved=false; | |
| 5011 | ✗ | } | |
| 5012 | ✗ | } | |
| 5013 | |||
| 5014 | ✗ | void zmap::PasteAll(const mapscr& copymapscr, int screen) | |
| 5015 | { | ||
| 5016 | ✗ | if(can_paste) | |
| 5017 | { | ||
| 5018 | ✗ | int32_t oldcolor=getcolor(); | |
| 5019 | ✗ | copy_mapscr(&screens[screen], ©mapscr); | |
| 5020 | ✗ | zinit.screen_data[cursor.map*MAPSCRS+cursor.screen] = copyscrdata; | |
| 5021 | //screens[screen]=copymapscr; | ||
| 5022 | ✗ | int32_t newcolor=getcolor(); | |
| 5023 | ✗ | loadlvlpal(newcolor); | |
| 5024 | |||
| 5025 | ✗ | screens[screen].valid|=mVALID; | |
| 5026 | |||
| 5027 | ✗ | if(newcolor!=oldcolor) | |
| 5028 | { | ||
| 5029 | ✗ | rebuild_trans_table(); | |
| 5030 | ✗ | } | |
| 5031 | |||
| 5032 | ✗ | saved=false; | |
| 5033 | ✗ | } | |
| 5034 | ✗ | } | |
| 5035 | |||
| 5036 | |||
| 5037 | ✗ | void zmap::PasteToAll(const mapscr& copymapscr) | |
| 5038 | { | ||
| 5039 | ✗ | if(can_paste) | |
| 5040 | { | ||
| 5041 | ✗ | int32_t oldcolor=getcolor(); | |
| 5042 | |||
| 5043 | ✗ | for(int32_t x=0; x<128; x++) | |
| 5044 | { | ||
| 5045 | ✗ | if(!(screens[x].valid&mVALID)) | |
| 5046 | { | ||
| 5047 | ✗ | screens[x].valid |= mVALID; | |
| 5048 | ✗ | screens[x].color = copymapscr.color; | |
| 5049 | ✗ | } | |
| 5050 | |||
| 5051 | ✗ | for(int32_t i=0; i<176; i++) | |
| 5052 | { | ||
| 5053 | ✗ | screens[x].data[i] = copymapscr.data[i]; | |
| 5054 | ✗ | screens[x].cset[i] = copymapscr.cset[i]; | |
| 5055 | ✗ | screens[x].sflag[i] = copymapscr.sflag[i]; | |
| 5056 | ✗ | } | |
| 5057 | ✗ | } | |
| 5058 | |||
| 5059 | ✗ | int32_t newcolor=getcolor(); | |
| 5060 | ✗ | loadlvlpal(newcolor); | |
| 5061 | |||
| 5062 | ✗ | if(!(screens[cursor.screen].valid&mVALID)) | |
| 5063 | { | ||
| 5064 | ✗ | newcolor=-1; | |
| 5065 | ✗ | } | |
| 5066 | |||
| 5067 | ✗ | if(newcolor!=oldcolor) | |
| 5068 | { | ||
| 5069 | ✗ | rebuild_trans_table(); | |
| 5070 | ✗ | } | |
| 5071 | |||
| 5072 | ✗ | saved=false; | |
| 5073 | ✗ | } | |
| 5074 | ✗ | } | |
| 5075 | |||
| 5076 | ✗ | void zmap::PasteAllToAll(const mapscr& copymapscr) | |
| 5077 | { | ||
| 5078 | ✗ | if(can_paste) | |
| 5079 | { | ||
| 5080 | ✗ | int32_t oldcolor=getcolor(); | |
| 5081 | |||
| 5082 | ✗ | for(int32_t x=0; x<128; x++) | |
| 5083 | { | ||
| 5084 | ✗ | copy_mapscr(&screens[x], ©mapscr); | |
| 5085 | ✗ | zinit.screen_data[cursor.map*MAPSCRS+x] = copyscrdata; | |
| 5086 | //screens[x]=copymapscr; | ||
| 5087 | ✗ | } | |
| 5088 | |||
| 5089 | ✗ | int32_t newcolor=getcolor(); | |
| 5090 | ✗ | loadlvlpal(newcolor); | |
| 5091 | |||
| 5092 | ✗ | if(!(screens[cursor.screen].valid&mVALID)) | |
| 5093 | { | ||
| 5094 | ✗ | newcolor=-1; | |
| 5095 | ✗ | } | |
| 5096 | |||
| 5097 | ✗ | if(newcolor!=oldcolor) | |
| 5098 | { | ||
| 5099 | ✗ | rebuild_trans_table(); | |
| 5100 | ✗ | } | |
| 5101 | |||
| 5102 | ✗ | saved=false; | |
| 5103 | ✗ | } | |
| 5104 | ✗ | } | |
| 5105 | |||
| 5106 | ✗ | void zmap::PasteEnemies(const mapscr& copymapscr, int screen) | |
| 5107 | { | ||
| 5108 | ✗ | if(can_paste) | |
| 5109 | { | ||
| 5110 | ✗ | for(int32_t i=0; i<10; i++) | |
| 5111 | ✗ | screens[screen].enemy[i]=copymapscr.enemy[i]; | |
| 5112 | ✗ | } | |
| 5113 | ✗ | } | |
| 5114 | |||
| 5115 | ✗ | void zmap::setCopyFFC(int32_t n) | |
| 5116 | { | ||
| 5117 | ✗ | copyffc = n; | |
| 5118 | ✗ | } | |
| 5119 | |||
| 5120 | ✗ | void zmap::update_combo_cycling() | |
| 5121 | { | ||
| 5122 | ✗ | if(!prv_mode||!prv_cmbcycle) | |
| 5123 | { | ||
| 5124 | ✗ | return; | |
| 5125 | } | ||
| 5126 | |||
| 5127 | int32_t x; | ||
| 5128 | int32_t newdata[176]; | ||
| 5129 | int32_t newcset[176]; | ||
| 5130 | ✗ | bool restartanim[MAXCOMBOS] = {0}; | |
| 5131 | |||
| 5132 | ✗ | for(int32_t i=0; i<176; i++) | |
| 5133 | { | ||
| 5134 | ✗ | newdata[i]=-1; | |
| 5135 | ✗ | newcset[i]=-1; | |
| 5136 | |||
| 5137 | ✗ | x=prvscr.data[i]; | |
| 5138 | |||
| 5139 | //time to restart | ||
| 5140 | ✗ | if((combobuf[x].aclk>=combobuf[x].speed) && | |
| 5141 | ✗ | (combobuf[x].tile-combobuf[x].frames>=combobuf[x].o_tile-1) && | |
| 5142 | ✗ | combobuf[x].can_cycle()) | |
| 5143 | { | ||
| 5144 | ✗ | bool cycle_under = (combobuf[x].animflags & AF_CYCLEUNDERCOMBO); | |
| 5145 | ✗ | newdata[i] = cycle_under ? prvscr.undercombo : combobuf[x].nextcombo; | |
| 5146 | |||
| 5147 | ✗ | if(!(combobuf[x].animflags & AF_CYCLENOCSET)) | |
| 5148 | ✗ | newcset[i] = cycle_under ? prvscr.undercset : combobuf[x].nextcset; | |
| 5149 | ✗ | int32_t c = newdata[i]; | |
| 5150 | |||
| 5151 | ✗ | if(combobuf[c].animflags & AF_CYCLE) | |
| 5152 | { | ||
| 5153 | ✗ | restartanim[c]=true; | |
| 5154 | ✗ | } | |
| 5155 | ✗ | } | |
| 5156 | ✗ | } | |
| 5157 | |||
| 5158 | ✗ | for(int32_t i=0; i<176; i++) | |
| 5159 | { | ||
| 5160 | ✗ | x=prvscr.data[i]; | |
| 5161 | |||
| 5162 | //time to restart | ||
| 5163 | ✗ | if((combobuf[x].aclk>=combobuf[x].speed) && | |
| 5164 | ✗ | (combobuf[x].tile-combobuf[x].frames>=combobuf[x].o_tile-1) && | |
| 5165 | ✗ | combobuf[x].can_cycle()) | |
| 5166 | { | ||
| 5167 | ✗ | bool cycle_under = (combobuf[x].animflags & AF_CYCLEUNDERCOMBO); | |
| 5168 | ✗ | newdata[i] = cycle_under ? prvscr.undercombo : combobuf[x].nextcombo; | |
| 5169 | |||
| 5170 | ✗ | if(!(combobuf[x].animflags & AF_CYCLENOCSET)) | |
| 5171 | ✗ | newcset[i] = cycle_under ? prvscr.undercset : combobuf[x].nextcset; | |
| 5172 | ✗ | int32_t c = newdata[i]; | |
| 5173 | |||
| 5174 | ✗ | if(combobuf[c].animflags & AF_CYCLE) | |
| 5175 | { | ||
| 5176 | ✗ | restartanim[c]=true; | |
| 5177 | ✗ | } | |
| 5178 | ✗ | } | |
| 5179 | ✗ | } | |
| 5180 | |||
| 5181 | ✗ | for(int32_t i=0; i<176; i++) | |
| 5182 | { | ||
| 5183 | ✗ | if(newdata[i]==-1) | |
| 5184 | ✗ | continue; | |
| 5185 | |||
| 5186 | ✗ | prvscr.data[i]=newdata[i]; | |
| 5187 | ✗ | prvscr.cset[i]=newcset[i]; | |
| 5188 | ✗ | } | |
| 5189 | |||
| 5190 | ✗ | word maxffc = prvscr.numFFC(); | |
| 5191 | ✗ | for(word i=0; i<maxffc; i++) | |
| 5192 | { | ||
| 5193 | ✗ | ffcdata& ffc = prvscr.ffcs[i]; | |
| 5194 | ✗ | newcombo const& cmb = combobuf[ffc.data]; | |
| 5195 | |||
| 5196 | //time to restart | ||
| 5197 | ✗ | if((cmb.aclk>=cmb.speed) && | |
| 5198 | ✗ | (cmb.tile-cmb.frames>=cmb.o_tile-1) && | |
| 5199 | ✗ | cmb.can_cycle()) | |
| 5200 | { | ||
| 5201 | ✗ | bool cycle_under = (cmb.animflags & AF_CYCLEUNDERCOMBO); | |
| 5202 | ✗ | ffc.data = cycle_under ? prvscr.undercombo : cmb.nextcombo; | |
| 5203 | |||
| 5204 | ✗ | if(!(cmb.animflags & AF_CYCLENOCSET)) | |
| 5205 | ✗ | newcset[i] = cycle_under ? prvscr.undercset : cmb.nextcset; | |
| 5206 | |||
| 5207 | ✗ | if(combobuf[ffc.data].animflags & AF_CYCLE) | |
| 5208 | { | ||
| 5209 | ✗ | restartanim[ffc.data]=true; | |
| 5210 | ✗ | } | |
| 5211 | ✗ | prvscr.ffcs[i].data = ffc.data; | |
| 5212 | ✗ | prvscr.ffcs[i].cset=ffc.cset; | |
| 5213 | ✗ | } | |
| 5214 | ✗ | } | |
| 5215 | |||
| 5216 | |||
| 5217 | ✗ | if(get_qr(qr_CMBCYCLELAYERS)) | |
| 5218 | { | ||
| 5219 | ✗ | for(int32_t j=0; j<6; j++) | |
| 5220 | { | ||
| 5221 | ✗ | if(!prvlayers[j].valid) | |
| 5222 | ✗ | continue; | |
| 5223 | |||
| 5224 | ✗ | for(int32_t i=0; i<176; i++) | |
| 5225 | { | ||
| 5226 | ✗ | newdata[i]=-1; | |
| 5227 | ✗ | newcset[i]=-1; | |
| 5228 | |||
| 5229 | ✗ | x=(prvlayers[j]).data[i]; | |
| 5230 | |||
| 5231 | //time to restart | ||
| 5232 | ✗ | if((combobuf[x].aclk>=combobuf[x].speed) && | |
| 5233 | ✗ | (combobuf[x].tile-combobuf[x].frames>=combobuf[x].o_tile-1) && | |
| 5234 | ✗ | combobuf[x].can_cycle()) | |
| 5235 | { | ||
| 5236 | ✗ | bool cycle_under = (combobuf[x].animflags & AF_CYCLEUNDERCOMBO); | |
| 5237 | ✗ | newdata[i] = cycle_under ? prvscr.undercombo : combobuf[x].nextcombo; | |
| 5238 | |||
| 5239 | ✗ | if(!(combobuf[x].animflags & AF_CYCLENOCSET)) | |
| 5240 | ✗ | newcset[i] = cycle_under ? prvscr.undercset : combobuf[x].nextcset; | |
| 5241 | ✗ | int32_t c = newdata[i]; | |
| 5242 | |||
| 5243 | ✗ | if(combobuf[c].animflags & AF_CYCLE) | |
| 5244 | { | ||
| 5245 | ✗ | restartanim[c]=true; | |
| 5246 | ✗ | } | |
| 5247 | ✗ | } | |
| 5248 | ✗ | } | |
| 5249 | |||
| 5250 | ✗ | for(int32_t i=0; i<176; i++) | |
| 5251 | { | ||
| 5252 | ✗ | x=(prvlayers[j]).data[i]; | |
| 5253 | |||
| 5254 | //time to restart | ||
| 5255 | ✗ | if((combobuf[x].aclk>=combobuf[x].speed) && | |
| 5256 | ✗ | (combobuf[x].tile-combobuf[x].frames>=combobuf[x].o_tile-1) && | |
| 5257 | ✗ | combobuf[x].can_cycle()) | |
| 5258 | { | ||
| 5259 | ✗ | bool cycle_under = (combobuf[x].animflags & AF_CYCLEUNDERCOMBO); | |
| 5260 | ✗ | newdata[i] = cycle_under ? prvscr.undercombo : combobuf[x].nextcombo; | |
| 5261 | |||
| 5262 | ✗ | if(!(combobuf[x].animflags & AF_CYCLENOCSET)) | |
| 5263 | ✗ | newcset[i] = cycle_under ? prvscr.undercset : combobuf[x].nextcset; | |
| 5264 | ✗ | int32_t c = newdata[i]; | |
| 5265 | |||
| 5266 | ✗ | if(combobuf[c].animflags & AF_CYCLE) | |
| 5267 | { | ||
| 5268 | ✗ | restartanim[c]=true; | |
| 5269 | ✗ | } | |
| 5270 | ✗ | } | |
| 5271 | ✗ | } | |
| 5272 | |||
| 5273 | ✗ | for(int32_t i=0; i<176; i++) | |
| 5274 | { | ||
| 5275 | ✗ | if(newdata[i]==-1) | |
| 5276 | ✗ | continue; | |
| 5277 | |||
| 5278 | ✗ | prvlayers[j].data[i]=newdata[i]; | |
| 5279 | ✗ | prvlayers[j].cset[i]=newcset[i]; | |
| 5280 | ✗ | } | |
| 5281 | ✗ | } | |
| 5282 | ✗ | } | |
| 5283 | |||
| 5284 | ✗ | for(int32_t i=0; i<MAXCOMBOS; i++) | |
| 5285 | { | ||
| 5286 | ✗ | if(restartanim[i]) | |
| 5287 | { | ||
| 5288 | ✗ | combobuf[i].tile = combobuf[i].o_tile; | |
| 5289 | ✗ | combobuf[i].cur_frame=0; | |
| 5290 | ✗ | combobuf[i].aclk = 0; | |
| 5291 | ✗ | } | |
| 5292 | ✗ | } | |
| 5293 | ✗ | } | |
| 5294 | |||
| 5295 | ✗ | void zmap::update_freeform_combos() | |
| 5296 | { | ||
| 5297 | ✗ | if(!prv_mode||!prv_cmbcycle) | |
| 5298 | { | ||
| 5299 | ✗ | return; | |
| 5300 | } | ||
| 5301 | |||
| 5302 | // TODO: this changer code is a duplicated here and for zplayer. Should fix that. | ||
| 5303 | ✗ | word maxffc = prvscr.numFFC(); | |
| 5304 | ✗ | for(int32_t i=0; i<maxffc; i++) | |
| 5305 | { | ||
| 5306 | ✗ | if(!(prvscr.ffcs[i].flags&ffc_changer) && prvscr.ffcs[i].data!=0 && !(prvscr.ffcs[i].flags&ffc_stationary)) | |
| 5307 | { | ||
| 5308 | ✗ | for(int32_t j=0; j<maxffc; j++) | |
| 5309 | { | ||
| 5310 | ✗ | if(i!=j) | |
| 5311 | { | ||
| 5312 | ✗ | if(prvscr.ffcs[j].flags&ffc_changer && prvscr.ffcs[j].data != 0) | |
| 5313 | { | ||
| 5314 | ✗ | if((((prvscr.ffcs[j].x.getInt())!=prvscr.ffcs[i].changer_x)||((prvscr.ffcs[j].y.getInt())!=prvscr.ffcs[i].changer_y))&&(prvscr.ffcs[i].link==0)) | |
| 5315 | { | ||
| 5316 | ✗ | if((isonline(prvscr.ffcs[i].x.getZLong(),prvscr.ffcs[i].y.getZLong(),prvscr.ffcs[i].prev_changer_x,prvscr.ffcs[i].prev_changer_y,prvscr.ffcs[j].x.getZLong(),prvscr.ffcs[j].y.getZLong())|| | |
| 5317 | ✗ | ((prvscr.ffcs[i].x.getZLong()==prvscr.ffcs[j].x.getZLong())&&(prvscr.ffcs[i].y.getZLong()==prvscr.ffcs[j].y.getZLong())))&&(prvscr.ffcs[i].prev_changer_x>-10000000&&prvscr.ffcs[i].prev_changer_y>-10000000)) | |
| 5318 | { | ||
| 5319 | //prvscr.ffcs[i].data=prvscr.ffcs[j].data; | ||
| 5320 | //prvscr.ffcs[i].cset=prvscr.ffcs[j].cset; | ||
| 5321 | ✗ | if(prvscr.ffcs[j].flags&ffc_changethis) | |
| 5322 | { | ||
| 5323 | ✗ | prvscr.ffcs[i].data = prvscr.ffcs[j].data; | |
| 5324 | ✗ | prvscr.ffcs[i].cset = prvscr.ffcs[j].cset; | |
| 5325 | ✗ | } | |
| 5326 | |||
| 5327 | ✗ | if(prvscr.ffcs[j].flags&ffc_changenext) | |
| 5328 | ✗ | prvscr.ffcs[i].data += 1; | |
| 5329 | |||
| 5330 | ✗ | if(prvscr.ffcs[j].flags&ffc_changeprev) | |
| 5331 | ✗ | prvscr.ffcs[i].data -= 1; | |
| 5332 | |||
| 5333 | ✗ | prvscr.ffcs[i].delay=prvscr.ffcs[j].delay; | |
| 5334 | ✗ | prvscr.ffcs[i].x=prvscr.ffcs[j].x; | |
| 5335 | ✗ | prvscr.ffcs[i].y=prvscr.ffcs[j].y; | |
| 5336 | |||
| 5337 | ✗ | prvscr.ffcs[i].vx=prvscr.ffcs[j].vx; | |
| 5338 | ✗ | prvscr.ffcs[i].vy=prvscr.ffcs[j].vy; | |
| 5339 | ✗ | prvscr.ffcs[i].ax=prvscr.ffcs[j].ax; | |
| 5340 | ✗ | prvscr.ffcs[i].ay=prvscr.ffcs[j].ay; | |
| 5341 | |||
| 5342 | ✗ | prvscr.ffcs[i].link=prvscr.ffcs[j].link; | |
| 5343 | ✗ | prvscr.ffcs[i].hit_width=prvscr.ffcs[j].hit_width; | |
| 5344 | ✗ | prvscr.ffcs[i].hit_height=prvscr.ffcs[j].hit_height; | |
| 5345 | ✗ | prvscr.ffcs[i].txsz=prvscr.ffcs[j].txsz; | |
| 5346 | ✗ | prvscr.ffcs[i].tysz=prvscr.ffcs[j].tysz; | |
| 5347 | |||
| 5348 | ✗ | if(prvscr.ffcs[i].flags&ffc_carryover) | |
| 5349 | ✗ | prvscr.ffcs[i].flags=prvscr.ffcs[j].flags&ffc_carryover; | |
| 5350 | ✗ | else prvscr.ffcs[i].flags=prvscr.ffcs[j].flags; | |
| 5351 | |||
| 5352 | ✗ | prvscr.ffcs[i].flags&=~ffc_changer; | |
| 5353 | ✗ | prvscr.ffcs[i].changer_x=(prvscr.ffcs[j].x.getInt()); | |
| 5354 | ✗ | prvscr.ffcs[i].changer_y=(prvscr.ffcs[j].y.getInt()); | |
| 5355 | |||
| 5356 | ✗ | if(combobuf[prvscr.ffcs[j].data].flag>15 && combobuf[prvscr.ffcs[j].data].flag<32) | |
| 5357 | { | ||
| 5358 | ✗ | prvscr.ffcs[j].data = prvscr.secretcombo[combobuf[prvscr.ffcs[j].data].flag - 16 + 4]; | |
| 5359 | ✗ | } | |
| 5360 | |||
| 5361 | ✗ | if((prvscr.ffcs[j].flags&ffc_swapnext)||(prvscr.ffcs[j].flags&ffc_swapprev)) | |
| 5362 | { | ||
| 5363 | ✗ | int32_t k=0; | |
| 5364 | |||
| 5365 | ✗ | if(prvscr.ffcs[j].flags&ffc_swapnext) | |
| 5366 | ✗ | k=j<(MAXFFCS-1)?j+1:0; | |
| 5367 | |||
| 5368 | ✗ | if(prvscr.ffcs[j].flags&ffc_swapprev) | |
| 5369 | ✗ | k=j>0?j-1:(MAXFFCS-1); | |
| 5370 | |||
| 5371 | ✗ | zc_swap(prvscr.ffcs[j].vx,prvscr.ffcs[k].vx); | |
| 5372 | ✗ | zc_swap(prvscr.ffcs[j].vy,prvscr.ffcs[k].vy); | |
| 5373 | ✗ | zc_swap(prvscr.ffcs[j].ax,prvscr.ffcs[k].ax); | |
| 5374 | ✗ | zc_swap(prvscr.ffcs[j].ay,prvscr.ffcs[k].ay); | |
| 5375 | ✗ | zc_swap(prvscr.ffcs[j].link,prvscr.ffcs[k].link); | |
| 5376 | ✗ | zc_swap(prvscr.ffcs[j].hit_width,prvscr.ffcs[k].hit_width); | |
| 5377 | ✗ | zc_swap(prvscr.ffcs[j].hit_height,prvscr.ffcs[k].hit_height); | |
| 5378 | ✗ | zc_swap(prvscr.ffcs[j].txsz,prvscr.ffcs[k].txsz); | |
| 5379 | ✗ | zc_swap(prvscr.ffcs[j].tysz,prvscr.ffcs[k].tysz); | |
| 5380 | ✗ | zc_swap(prvscr.ffcs[j].flags,prvscr.ffcs[k].flags); | |
| 5381 | ✗ | } | |
| 5382 | ✗ | } | |
| 5383 | ✗ | } | |
| 5384 | ✗ | } | |
| 5385 | ✗ | } | |
| 5386 | ✗ | } | |
| 5387 | |||
| 5388 | ✗ | if(prvscr.ffcs[i].link ? !prvscr.ffcs[prvscr.ffcs[i].link].delay : !prvscr.ffcs[i].delay) | |
| 5389 | { | ||
| 5390 | ✗ | if(prvscr.ffcs[i].link&&(prvscr.ffcs[i].link-1)!=i) | |
| 5391 | { | ||
| 5392 | ✗ | prvscr.ffcs[i].prev_changer_x = prvscr.ffcs[i].x.getZLong(); | |
| 5393 | ✗ | prvscr.ffcs[i].prev_changer_y = prvscr.ffcs[i].y.getZLong(); | |
| 5394 | ✗ | prvscr.ffcs[i].x+=prvscr.ffcs[prvscr.ffcs[i].link-1].vx; | |
| 5395 | ✗ | prvscr.ffcs[i].y+=prvscr.ffcs[prvscr.ffcs[i].link-1].vy; | |
| 5396 | ✗ | } | |
| 5397 | else | ||
| 5398 | { | ||
| 5399 | ✗ | prvscr.ffcs[i].prev_changer_x = prvscr.ffcs[i].x.getZLong(); | |
| 5400 | ✗ | prvscr.ffcs[i].prev_changer_y = prvscr.ffcs[i].y.getZLong(); | |
| 5401 | ✗ | prvscr.ffcs[i].x+=prvscr.ffcs[i].vx; | |
| 5402 | ✗ | prvscr.ffcs[i].y+=prvscr.ffcs[i].vy; | |
| 5403 | ✗ | prvscr.ffcs[i].vx+=prvscr.ffcs[i].ax; | |
| 5404 | ✗ | prvscr.ffcs[i].vy+=prvscr.ffcs[i].ay; | |
| 5405 | |||
| 5406 | ✗ | if(get_qr(qr_OLD_FFC_SPEED_CAP)) | |
| 5407 | { | ||
| 5408 | ✗ | if(prvscr.ffcs[i].vx>128) prvscr.ffcs[i].vx=128; | |
| 5409 | |||
| 5410 | ✗ | if(prvscr.ffcs[i].vx<-128) prvscr.ffcs[i].vx=-128; | |
| 5411 | |||
| 5412 | ✗ | if(prvscr.ffcs[i].vy>128) prvscr.ffcs[i].vy=128; | |
| 5413 | |||
| 5414 | ✗ | if(prvscr.ffcs[i].vy<-128) prvscr.ffcs[i].vy=-128; | |
| 5415 | ✗ | } | |
| 5416 | } | ||
| 5417 | ✗ | } | |
| 5418 | else | ||
| 5419 | { | ||
| 5420 | ✗ | if(!prvscr.ffcs[i].link || (prvscr.ffcs[i].link-1)==i) | |
| 5421 | ✗ | prvscr.ffcs[i].delay--; | |
| 5422 | } | ||
| 5423 | |||
| 5424 | ✗ | if(prvscr.ffcs[i].x<-32) | |
| 5425 | { | ||
| 5426 | ✗ | if(prvscr.flags6&fWRAPAROUNDFF) | |
| 5427 | { | ||
| 5428 | ✗ | prvscr.ffcs[i].x = (288+(prvscr.ffcs[i].x+32)); | |
| 5429 | ✗ | prvscr.ffcs[i].prev_changer_y = prvscr.ffcs[i].y.getZLong(); | |
| 5430 | ✗ | } | |
| 5431 | else | ||
| 5432 | { | ||
| 5433 | ✗ | prvscr.ffcs[i].data = 0; | |
| 5434 | ✗ | prvscr.ffcs[i].flags&=~ffc_carryover; | |
| 5435 | } | ||
| 5436 | ✗ | } | |
| 5437 | |||
| 5438 | ✗ | if(prvscr.ffcs[i].y<-32) | |
| 5439 | { | ||
| 5440 | ✗ | if(prvscr.flags6&fWRAPAROUNDFF) | |
| 5441 | { | ||
| 5442 | ✗ | prvscr.ffcs[i].y = 208+(prvscr.ffcs[i].y+32); | |
| 5443 | ✗ | prvscr.ffcs[i].prev_changer_x = prvscr.ffcs[i].x.getZLong(); | |
| 5444 | ✗ | } | |
| 5445 | else | ||
| 5446 | { | ||
| 5447 | ✗ | prvscr.ffcs[i].data = 0; | |
| 5448 | ✗ | prvscr.ffcs[i].flags&=~ffc_carryover; | |
| 5449 | } | ||
| 5450 | ✗ | } | |
| 5451 | |||
| 5452 | ✗ | if(prvscr.ffcs[i].x>=288) | |
| 5453 | { | ||
| 5454 | ✗ | if(prvscr.flags6&fWRAPAROUNDFF) | |
| 5455 | { | ||
| 5456 | ✗ | prvscr.ffcs[i].x = prvscr.ffcs[i].x-288-32; | |
| 5457 | ✗ | prvscr.ffcs[i].prev_changer_y = prvscr.ffcs[i].y.getZLong(); | |
| 5458 | ✗ | } | |
| 5459 | else | ||
| 5460 | { | ||
| 5461 | ✗ | prvscr.ffcs[i].data = 0; | |
| 5462 | ✗ | prvscr.ffcs[i].flags&=~ffc_carryover; | |
| 5463 | } | ||
| 5464 | ✗ | } | |
| 5465 | |||
| 5466 | ✗ | if(prvscr.ffcs[i].y>=208) | |
| 5467 | { | ||
| 5468 | ✗ | if(prvscr.flags6&fWRAPAROUNDFF) | |
| 5469 | { | ||
| 5470 | ✗ | prvscr.ffcs[i].y = prvscr.ffcs[i].y-208-32; | |
| 5471 | ✗ | prvscr.ffcs[i].prev_changer_y = prvscr.ffcs[i].x.getZLong(); | |
| 5472 | ✗ | } | |
| 5473 | else | ||
| 5474 | { | ||
| 5475 | ✗ | prvscr.ffcs[i].data = 0; | |
| 5476 | ✗ | prvscr.ffcs[i].flags&=~ffc_carryover; | |
| 5477 | } | ||
| 5478 | ✗ | } | |
| 5479 | |||
| 5480 | ✗ | } | |
| 5481 | ✗ | } | |
| 5482 | ✗ | } | |
| 5483 | |||
| 5484 | ✗ | void zmap::goto_dmapscr(int dmap, int scr) | |
| 5485 | { | ||
| 5486 | ✗ | setCurrMap(DMaps[dmap].map); | |
| 5487 | ✗ | setCurrScr(scr+DMaps[dmap].xoff); | |
| 5488 | ✗ | } | |
| 5489 | ✗ | void zmap::goto_mapscr(int map, int scr) | |
| 5490 | { | ||
| 5491 | ✗ | setCurrMap(map); | |
| 5492 | ✗ | setCurrScr(scr); | |
| 5493 | ✗ | } | |
| 5494 | |||
| 5495 | ✗ | void zmap::dowarp(int32_t type, int32_t index) | |
| 5496 | { | ||
| 5497 | ✗ | set_warpback(); | |
| 5498 | ✗ | if(type==0) | |
| 5499 | { | ||
| 5500 | |||
| 5501 | ✗ | int32_t dmap=screens[cursor.screen].tilewarpdmap[index]; | |
| 5502 | ✗ | int32_t scr=screens[cursor.screen].tilewarpscr[index]; | |
| 5503 | |||
| 5504 | ✗ | switch(screens[cursor.screen].tilewarptype[index]) | |
| 5505 | { | ||
| 5506 | case wtCAVE: | ||
| 5507 | case wtNOWARP: | ||
| 5508 | ✗ | break; | |
| 5509 | |||
| 5510 | default: | ||
| 5511 | ✗ | goto_dmapscr(dmap, scr); | |
| 5512 | ✗ | break; | |
| 5513 | } | ||
| 5514 | ✗ | } | |
| 5515 | ✗ | else if(type==1) | |
| 5516 | { | ||
| 5517 | ✗ | int32_t dmap=screens[cursor.screen].sidewarpdmap[index]; | |
| 5518 | ✗ | int32_t scr=screens[cursor.screen].sidewarpscr[index]; | |
| 5519 | |||
| 5520 | ✗ | switch(screens[cursor.screen].sidewarptype[index]) | |
| 5521 | { | ||
| 5522 | case wtCAVE: | ||
| 5523 | case wtNOWARP: | ||
| 5524 | ✗ | break; | |
| 5525 | |||
| 5526 | default: | ||
| 5527 | ✗ | goto_dmapscr(dmap, scr); | |
| 5528 | ✗ | break; | |
| 5529 | } | ||
| 5530 | ✗ | } | |
| 5531 | ✗ | } | |
| 5532 | |||
| 5533 | extern int32_t prv_twon; | ||
| 5534 | |||
| 5535 | ✗ | void zmap::prv_dowarp(int32_t type, int32_t index) | |
| 5536 | { | ||
| 5537 | ✗ | if(type==0) | |
| 5538 | { | ||
| 5539 | |||
| 5540 | ✗ | int32_t dmap=prvscr.tilewarpdmap[index]; | |
| 5541 | ✗ | int32_t scr=prvscr.tilewarpscr[index]; | |
| 5542 | |||
| 5543 | ✗ | switch(prvscr.tilewarptype[index]) | |
| 5544 | { | ||
| 5545 | case wtCAVE: | ||
| 5546 | case wtNOWARP: | ||
| 5547 | ✗ | break; | |
| 5548 | |||
| 5549 | default: | ||
| 5550 | //setCurrMap(DMaps[dmap].map); | ||
| 5551 | //setCurrScr(scr+DMaps[dmap].xoff); | ||
| 5552 | ✗ | set_prvscr(DMaps[dmap].map,scr+DMaps[dmap].xoff); | |
| 5553 | ✗ | loadlvlpal(getcolor()); | |
| 5554 | ✗ | rebuild_trans_table(); | |
| 5555 | //prv_cmbcycle=0; | ||
| 5556 | ✗ | break; | |
| 5557 | } | ||
| 5558 | ✗ | } | |
| 5559 | ✗ | else if(type==1) | |
| 5560 | { | ||
| 5561 | ✗ | int32_t dmap=prvscr.sidewarpdmap[index]; | |
| 5562 | ✗ | int32_t scr=prvscr.sidewarpscr[index]; | |
| 5563 | |||
| 5564 | ✗ | switch(prvscr.sidewarptype[index]) | |
| 5565 | { | ||
| 5566 | case wtCAVE: | ||
| 5567 | case wtNOWARP: | ||
| 5568 | ✗ | break; | |
| 5569 | |||
| 5570 | default: | ||
| 5571 | //setCurrMap(DMaps[dmap].map); | ||
| 5572 | //setCurrScr(scr+DMaps[dmap].xoff); | ||
| 5573 | ✗ | set_prvscr(DMaps[dmap].map,scr+DMaps[dmap].xoff); | |
| 5574 | ✗ | loadlvlpal(getcolor()); | |
| 5575 | ✗ | rebuild_trans_table(); | |
| 5576 | //prv_cmbcycle=0; | ||
| 5577 | ✗ | break; | |
| 5578 | } | ||
| 5579 | ✗ | } | |
| 5580 | |||
| 5581 | ✗ | if(prv_twon) | |
| 5582 | { | ||
| 5583 | ✗ | prv_time=get_prvscr()->timedwarptics; | |
| 5584 | ✗ | } | |
| 5585 | ✗ | } | |
| 5586 | |||
| 5587 | ✗ | void zmap::dowarp2(int32_t ring,int32_t index) | |
| 5588 | { | ||
| 5589 | ✗ | set_warpback(); | |
| 5590 | ✗ | goto_dmapscr(QMisc.warp[ring].dmap[index], QMisc.warp[ring].scr[index]); | |
| 5591 | ✗ | } | |
| 5592 | |||
| 5593 | ✗ | void zmap::set_warpback() | |
| 5594 | { | ||
| 5595 | ✗ | warpbackmap = cursor.map; | |
| 5596 | ✗ | warpbackscreen = cursor.screen; | |
| 5597 | ✗ | } | |
| 5598 | ✗ | bool zmap::has_warpback() | |
| 5599 | { | ||
| 5600 | ✗ | return warpbackmap && warpbackscreen | |
| 5601 | ✗ | && !(warpbackmap == cursor.map && warpbackscreen == cursor.screen); | |
| 5602 | } | ||
| 5603 | ✗ | void zmap::warpback() | |
| 5604 | { | ||
| 5605 | ✗ | if(!has_warpback()) | |
| 5606 | ✗ | return; | |
| 5607 | |||
| 5608 | ✗ | int m = cursor.map, s = cursor.screen; | |
| 5609 | ✗ | goto_mapscr(*warpbackmap, *warpbackscreen); | |
| 5610 | ✗ | warpbackmap = m; | |
| 5611 | ✗ | warpbackscreen = s; | |
| 5612 | ✗ | } | |
| 5613 | |||
| 5614 | ✗ | bool save_msgstrs(const char *path) | |
| 5615 | { | ||
| 5616 | ✗ | PACKFILE *f = pack_fopen_password(path,F_WRITE, ""); | |
| 5617 | |||
| 5618 | ✗ | if(!f) | |
| 5619 | { | ||
| 5620 | ✗ | return false; | |
| 5621 | } | ||
| 5622 | |||
| 5623 | ✗ | if(writestrings(f, ZELDA_VERSION, VERSION_BUILD, 0, MAXMSGS)==0) | |
| 5624 | { | ||
| 5625 | ✗ | pack_fclose(f); | |
| 5626 | ✗ | return true; | |
| 5627 | } | ||
| 5628 | |||
| 5629 | ✗ | pack_fclose(f); | |
| 5630 | ✗ | return false; | |
| 5631 | ✗ | } | |
| 5632 | |||
| 5633 | 1 | bool save_strings_tsv(const char *path) | |
| 5634 | { | ||
| 5635 | 1 | PACKFILE *f = pack_fopen_password(path,F_WRITE, ""); | |
| 5636 | |||
| 5637 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(!f) |
| 5638 | { | ||
| 5639 | ✗ | return false; | |
| 5640 | } | ||
| 5641 | |||
| 5642 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(writestrings_tsv(f)==0) |
| 5643 | { | ||
| 5644 | 1 | pack_fclose(f); | |
| 5645 | 1 | return true; | |
| 5646 | } | ||
| 5647 | |||
| 5648 | ✗ | pack_fclose(f); | |
| 5649 | ✗ | return false; | |
| 5650 | 1 | } | |
| 5651 | |||
| 5652 | ✗ | bool save_msgstrs_text(const char *path) | |
| 5653 | { | ||
| 5654 | ✗ | PACKFILE *f = pack_fopen_password(path,F_WRITE, ""); | |
| 5655 | |||
| 5656 | ✗ | if(!f) | |
| 5657 | { | ||
| 5658 | ✗ | return false; | |
| 5659 | } | ||
| 5660 | |||
| 5661 | ✗ | if(writestrings_text(f)==0) | |
| 5662 | { | ||
| 5663 | ✗ | pack_fclose(f); | |
| 5664 | ✗ | return true; | |
| 5665 | } | ||
| 5666 | |||
| 5667 | ✗ | pack_fclose(f); | |
| 5668 | ✗ | return false; | |
| 5669 | ✗ | } | |
| 5670 | |||
| 5671 | ✗ | bool load_msgstrs(const char *path, int32_t startstring) | |
| 5672 | { | ||
| 5673 | //these are here to bypass compiler warnings about unused arguments | ||
| 5674 | ✗ | startstring=startstring; | |
| 5675 | |||
| 5676 | dword section_id; | ||
| 5677 | ✗ | PACKFILE *f = pack_fopen_password(path,F_READ, ""); | |
| 5678 | |||
| 5679 | ✗ | if(!f) | |
| 5680 | { | ||
| 5681 | ✗ | return false; | |
| 5682 | } | ||
| 5683 | |||
| 5684 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 5685 | { | ||
| 5686 | ✗ | return false; | |
| 5687 | } | ||
| 5688 | |||
| 5689 | ✗ | if(section_id==ID_STRINGS) | |
| 5690 | { | ||
| 5691 | ✗ | if(readstrings(f, &header)==0) | |
| 5692 | { | ||
| 5693 | ✗ | pack_fclose(f); | |
| 5694 | ✗ | return true; | |
| 5695 | } | ||
| 5696 | else | ||
| 5697 | { | ||
| 5698 | ✗ | pack_fclose(f); | |
| 5699 | ✗ | return false; | |
| 5700 | } | ||
| 5701 | } | ||
| 5702 | |||
| 5703 | ✗ | pack_fclose(f); | |
| 5704 | ✗ | return false; | |
| 5705 | ✗ | } | |
| 5706 | |||
| 5707 | ✗ | bool load_strings_tsv(const char *path) | |
| 5708 | { | ||
| 5709 | try | ||
| 5710 | { | ||
| 5711 | ✗ | parse_strings_tsv(util::read_text_file(path)); | |
| 5712 | ✗ | } | |
| 5713 | catch (std::exception& ex) | ||
| 5714 | { | ||
| 5715 | ✗ | InfoDialog("Import .tsv Error", ex.what()).show(); | |
| 5716 | ✗ | return false; | |
| 5717 | ✗ | } | |
| 5718 | ✗ | return true; | |
| 5719 | ✗ | } | |
| 5720 | |||
| 5721 | ✗ | bool save_pals(const char *path) | |
| 5722 | { | ||
| 5723 | ✗ | PACKFILE *f = pack_fopen_password(path,F_WRITE, ""); | |
| 5724 | |||
| 5725 | ✗ | if(!f) | |
| 5726 | { | ||
| 5727 | ✗ | return false; | |
| 5728 | } | ||
| 5729 | |||
| 5730 | ✗ | if(writecolordata(f, ZELDA_VERSION, VERSION_BUILD, 0, newerpdTOTAL)==0) | |
| 5731 | { | ||
| 5732 | ✗ | pack_fclose(f); | |
| 5733 | ✗ | return true; | |
| 5734 | } | ||
| 5735 | |||
| 5736 | ✗ | pack_fclose(f); | |
| 5737 | ✗ | return false; | |
| 5738 | ✗ | } | |
| 5739 | |||
| 5740 | ✗ | bool load_pals(const char *path, int32_t startcset) | |
| 5741 | { | ||
| 5742 | dword section_id; | ||
| 5743 | ✗ | PACKFILE *f = pack_fopen_password(path,F_READ, ""); | |
| 5744 | |||
| 5745 | ✗ | if(!f) | |
| 5746 | { | ||
| 5747 | ✗ | return false; | |
| 5748 | } | ||
| 5749 | |||
| 5750 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 5751 | { | ||
| 5752 | ✗ | return false; | |
| 5753 | } | ||
| 5754 | |||
| 5755 | ✗ | if(section_id==ID_CSETS) | |
| 5756 | { | ||
| 5757 | ✗ | if(readcolordata(f, &QMisc, 0x250, 33, startcset, newerpdTOTAL-startcset)==0) | |
| 5758 | { | ||
| 5759 | ✗ | pack_fclose(f); | |
| 5760 | ✗ | loadlvlpal(Color); | |
| 5761 | ✗ | return true; | |
| 5762 | } | ||
| 5763 | else | ||
| 5764 | { | ||
| 5765 | ✗ | pack_fclose(f); | |
| 5766 | ✗ | return false; | |
| 5767 | } | ||
| 5768 | } | ||
| 5769 | |||
| 5770 | ✗ | return false; | |
| 5771 | ✗ | } | |
| 5772 | |||
| 5773 | int32_t writeguys(PACKFILE *f, zquestheader *Header); | ||
| 5774 | ✗ | bool save_guys(const char *path) | |
| 5775 | { | ||
| 5776 | ✗ | PACKFILE *f = pack_fopen_password(path,F_WRITE, ""); | |
| 5777 | |||
| 5778 | ✗ | if(!f) | |
| 5779 | { | ||
| 5780 | ✗ | return false; | |
| 5781 | } | ||
| 5782 | |||
| 5783 | /* | ||
| 5784 | int32_t id = ID_GUYS; | ||
| 5785 | if(!p_mputl(id,f)) | ||
| 5786 | { | ||
| 5787 | return false; | ||
| 5788 | } | ||
| 5789 | */ | ||
| 5790 | |||
| 5791 | ✗ | zquestheader h; | |
| 5792 | ✗ | h.zelda_version = 0x250; | |
| 5793 | ✗ | h.build = 21; | |
| 5794 | |||
| 5795 | ✗ | if(writeguys(f, &h)==0) | |
| 5796 | { | ||
| 5797 | ✗ | pack_fclose(f); | |
| 5798 | ✗ | return true; | |
| 5799 | } | ||
| 5800 | |||
| 5801 | ✗ | pack_fclose(f); | |
| 5802 | ✗ | return false; | |
| 5803 | ✗ | } | |
| 5804 | |||
| 5805 | ✗ | bool load_guys(const char *path) | |
| 5806 | { | ||
| 5807 | dword section_id; | ||
| 5808 | ✗ | PACKFILE *f = pack_fopen_password(path,F_READ, ""); | |
| 5809 | |||
| 5810 | ✗ | if(!f) | |
| 5811 | { | ||
| 5812 | ✗ | return false; | |
| 5813 | } | ||
| 5814 | |||
| 5815 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 5816 | { | ||
| 5817 | ✗ | pack_fclose(f); | |
| 5818 | ✗ | return false; | |
| 5819 | } | ||
| 5820 | |||
| 5821 | ✗ | zquestheader h; | |
| 5822 | ✗ | h.zelda_version = 0x250; | |
| 5823 | ✗ | h.build = 21; | |
| 5824 | |||
| 5825 | ✗ | if(section_id==ID_GUYS) | |
| 5826 | { | ||
| 5827 | ✗ | if(readguys(f, &h)==0) | |
| 5828 | { | ||
| 5829 | ✗ | pack_fclose(f); | |
| 5830 | ✗ | return true; | |
| 5831 | } | ||
| 5832 | ✗ | } | |
| 5833 | |||
| 5834 | ✗ | pack_fclose(f); | |
| 5835 | ✗ | return false; | |
| 5836 | ✗ | } | |
| 5837 | |||
| 5838 | |||
| 5839 | //int32_t writeguys(PACKFILE *f, zquestheader *Header); | ||
| 5840 | ✗ | bool save_combo_alias(const char *path) | |
| 5841 | { | ||
| 5842 | ✗ | PACKFILE *f = pack_fopen_password(path,F_WRITE, ""); | |
| 5843 | |||
| 5844 | ✗ | if(!f) | |
| 5845 | { | ||
| 5846 | ✗ | return false; | |
| 5847 | } | ||
| 5848 | |||
| 5849 | ✗ | zquestheader h; | |
| 5850 | ✗ | h.zelda_version = 0x250; | |
| 5851 | ✗ | h.build = 21; | |
| 5852 | |||
| 5853 | ✗ | if(writecomboaliases(f, 0, 0)==0) | |
| 5854 | { | ||
| 5855 | ✗ | pack_fclose(f); | |
| 5856 | ✗ | return true; | |
| 5857 | } | ||
| 5858 | |||
| 5859 | ✗ | pack_fclose(f); | |
| 5860 | ✗ | return false; | |
| 5861 | ✗ | } | |
| 5862 | |||
| 5863 | ✗ | bool load_combo_alias(const char *path) | |
| 5864 | { | ||
| 5865 | dword section_id; | ||
| 5866 | ✗ | PACKFILE *f = pack_fopen_password(path,F_READ, ""); | |
| 5867 | |||
| 5868 | ✗ | if(!f) | |
| 5869 | { | ||
| 5870 | ✗ | return false; | |
| 5871 | } | ||
| 5872 | |||
| 5873 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 5874 | { | ||
| 5875 | ✗ | pack_fclose(f); | |
| 5876 | ✗ | return false; | |
| 5877 | } | ||
| 5878 | |||
| 5879 | ✗ | zquestheader h; | |
| 5880 | ✗ | h.zelda_version = 0x250; | |
| 5881 | ✗ | h.build = 21; | |
| 5882 | |||
| 5883 | ✗ | if(section_id==ID_COMBOALIASES) | |
| 5884 | { | ||
| 5885 | ✗ | if(readcomboaliases(f, &h, 0, 0)==0) | |
| 5886 | { | ||
| 5887 | ✗ | pack_fclose(f); | |
| 5888 | ✗ | return true; | |
| 5889 | } | ||
| 5890 | ✗ | } | |
| 5891 | |||
| 5892 | ✗ | pack_fclose(f); | |
| 5893 | ✗ | return false; | |
| 5894 | ✗ | } | |
| 5895 | |||
| 5896 | ✗ | bool load_zgp(const char *path) | |
| 5897 | { | ||
| 5898 | dword section_id; | ||
| 5899 | word section_version; | ||
| 5900 | ✗ | PACKFILE *f=pack_fopen_password(path,F_READ,""); | |
| 5901 | |||
| 5902 | ✗ | if(!f) | |
| 5903 | ✗ | return false; | |
| 5904 | |||
| 5905 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 5906 | { | ||
| 5907 | ✗ | pack_fclose(f); | |
| 5908 | ✗ | return false; | |
| 5909 | } | ||
| 5910 | |||
| 5911 | ✗ | if(section_id!=ID_GRAPHICSPACK) | |
| 5912 | { | ||
| 5913 | ✗ | pack_fclose(f); | |
| 5914 | ✗ | return false; | |
| 5915 | } | ||
| 5916 | |||
| 5917 | //section version info | ||
| 5918 | ✗ | if(!p_igetw(§ion_version,f)) | |
| 5919 | { | ||
| 5920 | ✗ | return 2; | |
| 5921 | } | ||
| 5922 | |||
| 5923 | ✗ | if(!read_deprecated_section_cversion(f)) | |
| 5924 | { | ||
| 5925 | ✗ | return 3; | |
| 5926 | } | ||
| 5927 | |||
| 5928 | //tiles | ||
| 5929 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 5930 | { | ||
| 5931 | ✗ | pack_fclose(f); | |
| 5932 | ✗ | return false; | |
| 5933 | } | ||
| 5934 | |||
| 5935 | ✗ | if(section_id==ID_TILES) | |
| 5936 | { | ||
| 5937 | ✗ | if(readtiles(f, newtilebuf, NULL, ZELDA_VERSION, VERSION_BUILD, 0, NEWMAXTILES, false)!=0) | |
| 5938 | { | ||
| 5939 | ✗ | pack_fclose(f); | |
| 5940 | ✗ | init_tiles(true, &header); | |
| 5941 | ✗ | return false; | |
| 5942 | } | ||
| 5943 | ✗ | } | |
| 5944 | else | ||
| 5945 | { | ||
| 5946 | ✗ | pack_fclose(f); | |
| 5947 | ✗ | return false; | |
| 5948 | } | ||
| 5949 | |||
| 5950 | //combos | ||
| 5951 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 5952 | { | ||
| 5953 | ✗ | pack_fclose(f); | |
| 5954 | ✗ | return false; | |
| 5955 | } | ||
| 5956 | |||
| 5957 | ✗ | if(section_id==ID_COMBOS) | |
| 5958 | { | ||
| 5959 | ✗ | if(readcombos(f, NULL, ZELDA_VERSION, VERSION_BUILD, 0, MAXCOMBOS)!=0) | |
| 5960 | { | ||
| 5961 | ✗ | pack_fclose(f); | |
| 5962 | ✗ | return false; | |
| 5963 | } | ||
| 5964 | ✗ | } | |
| 5965 | else | ||
| 5966 | { | ||
| 5967 | ✗ | pack_fclose(f); | |
| 5968 | ✗ | return false; | |
| 5969 | } | ||
| 5970 | |||
| 5971 | //palettes | ||
| 5972 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 5973 | { | ||
| 5974 | ✗ | pack_fclose(f); | |
| 5975 | ✗ | return false; | |
| 5976 | } | ||
| 5977 | |||
| 5978 | ✗ | if(section_id==ID_CSETS) | |
| 5979 | { | ||
| 5980 | ✗ | if(readcolordata(f, &QMisc, ZELDA_VERSION, VERSION_BUILD, 0, newerpdTOTAL)!=0) | |
| 5981 | { | ||
| 5982 | ✗ | pack_fclose(f); | |
| 5983 | ✗ | return false; | |
| 5984 | } | ||
| 5985 | ✗ | } | |
| 5986 | else | ||
| 5987 | { | ||
| 5988 | ✗ | pack_fclose(f); | |
| 5989 | ✗ | return false; | |
| 5990 | } | ||
| 5991 | |||
| 5992 | //items | ||
| 5993 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 5994 | { | ||
| 5995 | ✗ | pack_fclose(f); | |
| 5996 | ✗ | return false; | |
| 5997 | } | ||
| 5998 | |||
| 5999 | ✗ | if(section_id==ID_ITEMS) | |
| 6000 | { | ||
| 6001 | ✗ | if(readitems(f, ZELDA_VERSION, VERSION_BUILD)!=0) | |
| 6002 | { | ||
| 6003 | ✗ | pack_fclose(f); | |
| 6004 | ✗ | return false; | |
| 6005 | } | ||
| 6006 | ✗ | } | |
| 6007 | else | ||
| 6008 | { | ||
| 6009 | ✗ | pack_fclose(f); | |
| 6010 | ✗ | return false; | |
| 6011 | } | ||
| 6012 | |||
| 6013 | //weapons | ||
| 6014 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 6015 | { | ||
| 6016 | ✗ | pack_fclose(f); | |
| 6017 | ✗ | return false; | |
| 6018 | } | ||
| 6019 | |||
| 6020 | ✗ | if(section_id==ID_WEAPONS) | |
| 6021 | { | ||
| 6022 | ✗ | if(readweapons(f, &header)!=0) | |
| 6023 | { | ||
| 6024 | ✗ | pack_fclose(f); | |
| 6025 | ✗ | return false; | |
| 6026 | } | ||
| 6027 | ✗ | } | |
| 6028 | else | ||
| 6029 | { | ||
| 6030 | ✗ | pack_fclose(f); | |
| 6031 | ✗ | return false; | |
| 6032 | } | ||
| 6033 | |||
| 6034 | //read the triforce pieces info and make sure it worked | ||
| 6035 | //really do this? | ||
| 6036 | |||
| 6037 | //read the game icons info and make sure it worked | ||
| 6038 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 6039 | { | ||
| 6040 | ✗ | pack_fclose(f); | |
| 6041 | ✗ | return false; | |
| 6042 | } | ||
| 6043 | |||
| 6044 | ✗ | if(section_id==ID_ICONS) | |
| 6045 | { | ||
| 6046 | ✗ | if(readgameicons(f, &header, &QMisc)!=0) | |
| 6047 | { | ||
| 6048 | ✗ | pack_fclose(f); | |
| 6049 | ✗ | return false; | |
| 6050 | } | ||
| 6051 | ✗ | } | |
| 6052 | else | ||
| 6053 | { | ||
| 6054 | ✗ | pack_fclose(f); | |
| 6055 | ✗ | return false; | |
| 6056 | } | ||
| 6057 | |||
| 6058 | //read the misc colors info and map styles info and make sure it worked | ||
| 6059 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 6060 | { | ||
| 6061 | ✗ | pack_fclose(f); | |
| 6062 | ✗ | return false; | |
| 6063 | } | ||
| 6064 | |||
| 6065 | ✗ | if(section_id==ID_COLORS) | |
| 6066 | { | ||
| 6067 | ✗ | if(readmisccolors(f, &header, &QMisc)!=0) | |
| 6068 | { | ||
| 6069 | ✗ | pack_fclose(f); | |
| 6070 | ✗ | return false; | |
| 6071 | } | ||
| 6072 | ✗ | } | |
| 6073 | else | ||
| 6074 | { | ||
| 6075 | ✗ | pack_fclose(f); | |
| 6076 | ✗ | return false; | |
| 6077 | } | ||
| 6078 | |||
| 6079 | //read the door combo sets and make sure it worked | ||
| 6080 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 6081 | { | ||
| 6082 | ✗ | pack_fclose(f); | |
| 6083 | ✗ | return false; | |
| 6084 | } | ||
| 6085 | |||
| 6086 | ✗ | if(section_id==ID_DOORS) | |
| 6087 | { | ||
| 6088 | ✗ | if(readdoorcombosets(f, &header)!=0) | |
| 6089 | { | ||
| 6090 | ✗ | pack_fclose(f); | |
| 6091 | ✗ | return false; | |
| 6092 | } | ||
| 6093 | ✗ | } | |
| 6094 | else | ||
| 6095 | { | ||
| 6096 | ✗ | pack_fclose(f); | |
| 6097 | ✗ | return false; | |
| 6098 | } | ||
| 6099 | |||
| 6100 | //read the template screens and make sure it worked | ||
| 6101 | //really do this? | ||
| 6102 | |||
| 6103 | //yay! it worked! close the file and say everything was ok. | ||
| 6104 | ✗ | loadlvlpal(Color); | |
| 6105 | ✗ | setup_combo_animations(); | |
| 6106 | ✗ | setup_combo_animations2(); | |
| 6107 | ✗ | pack_fclose(f); | |
| 6108 | ✗ | return true; | |
| 6109 | ✗ | } | |
| 6110 | |||
| 6111 | ✗ | bool save_zgp(const char *path) | |
| 6112 | { | ||
| 6113 | ✗ | reset_combo_animations(); | |
| 6114 | ✗ | reset_combo_animations2(); | |
| 6115 | |||
| 6116 | //open the file | ||
| 6117 | ✗ | PACKFILE *f=pack_fopen_password(path,F_WRITE, ""); | |
| 6118 | |||
| 6119 | ✗ | if(!f) | |
| 6120 | ✗ | return false; | |
| 6121 | |||
| 6122 | ✗ | dword section_id=ID_GRAPHICSPACK; | |
| 6123 | ✗ | dword section_version=V_GRAPHICSPACK; | |
| 6124 | |||
| 6125 | //section id | ||
| 6126 | ✗ | if(!p_mputl(section_id,f)) | |
| 6127 | { | ||
| 6128 | ✗ | return 1; | |
| 6129 | } | ||
| 6130 | |||
| 6131 | //section version info | ||
| 6132 | ✗ | if(!p_iputw(section_version,f)) | |
| 6133 | { | ||
| 6134 | ✗ | return 2; | |
| 6135 | } | ||
| 6136 | |||
| 6137 | ✗ | if(!write_deprecated_section_cversion(section_version,f)) | |
| 6138 | { | ||
| 6139 | ✗ | return 3; | |
| 6140 | } | ||
| 6141 | |||
| 6142 | //tiles | ||
| 6143 | ✗ | if(writetiles(f, ZELDA_VERSION, VERSION_BUILD, 0, NEWMAXTILES)!=0) | |
| 6144 | { | ||
| 6145 | ✗ | pack_fclose(f); | |
| 6146 | ✗ | return false; | |
| 6147 | } | ||
| 6148 | |||
| 6149 | //combos | ||
| 6150 | ✗ | if(writecombos(f, ZELDA_VERSION, VERSION_BUILD, 0, MAXCOMBOS)!=0) | |
| 6151 | { | ||
| 6152 | ✗ | pack_fclose(f); | |
| 6153 | ✗ | return false; | |
| 6154 | } | ||
| 6155 | |||
| 6156 | //palettes | ||
| 6157 | ✗ | if(writecolordata(f, ZELDA_VERSION, VERSION_BUILD, 0, newerpdTOTAL)!=0) | |
| 6158 | { | ||
| 6159 | ✗ | pack_fclose(f); | |
| 6160 | ✗ | return false; | |
| 6161 | } | ||
| 6162 | |||
| 6163 | //items | ||
| 6164 | ✗ | if(writeitems(f, &header)!=0) | |
| 6165 | { | ||
| 6166 | ✗ | pack_fclose(f); | |
| 6167 | ✗ | return false; | |
| 6168 | } | ||
| 6169 | |||
| 6170 | //weapons | ||
| 6171 | ✗ | if(writeweapons(f, &header)!=0) | |
| 6172 | { | ||
| 6173 | ✗ | pack_fclose(f); | |
| 6174 | ✗ | return false; | |
| 6175 | } | ||
| 6176 | |||
| 6177 | //write the triforce pieces info and make sure it worked | ||
| 6178 | //really do this? | ||
| 6179 | |||
| 6180 | //write the game icons info and make sure it worked | ||
| 6181 | ✗ | if(writegameicons(f, &header)!=0) | |
| 6182 | { | ||
| 6183 | ✗ | pack_fclose(f); | |
| 6184 | ✗ | return false; | |
| 6185 | } | ||
| 6186 | |||
| 6187 | //write the misc colors info and map styles info and make sure it worked | ||
| 6188 | ✗ | if(writemisccolors(f, &header)!=0) | |
| 6189 | { | ||
| 6190 | ✗ | pack_fclose(f); | |
| 6191 | ✗ | return false; | |
| 6192 | } | ||
| 6193 | |||
| 6194 | //write the door combo sets and make sure it worked | ||
| 6195 | ✗ | if(writedoorcombosets(f, &header)!=0) | |
| 6196 | { | ||
| 6197 | ✗ | pack_fclose(f); | |
| 6198 | ✗ | return false; | |
| 6199 | } | ||
| 6200 | |||
| 6201 | //write the template screens and make sure it worked | ||
| 6202 | //really do this? | ||
| 6203 | |||
| 6204 | ✗ | pack_fclose(f); | |
| 6205 | ✗ | return true; | |
| 6206 | ✗ | } | |
| 6207 | |||
| 6208 | ✗ | bool save_subscreen(const char *path, ZCSubscreen const& savefrom) | |
| 6209 | { | ||
| 6210 | //open the file | ||
| 6211 | ✗ | PACKFILE *f=pack_fopen_password(path,F_WRITE, ""); | |
| 6212 | |||
| 6213 | ✗ | if(!f) | |
| 6214 | ✗ | return false; | |
| 6215 | |||
| 6216 | ✗ | dword section_id=ID_SUBSCREEN; | |
| 6217 | ✗ | dword s_version=V_SUBSCREEN; | |
| 6218 | |||
| 6219 | ✗ | if(!p_mputl(section_id,f)) | |
| 6220 | { | ||
| 6221 | ✗ | pack_fclose(f); | |
| 6222 | ✗ | return false; | |
| 6223 | } | ||
| 6224 | |||
| 6225 | ✗ | if(!p_iputw(s_version,f)) | |
| 6226 | { | ||
| 6227 | ✗ | pack_fclose(f); | |
| 6228 | ✗ | return false; | |
| 6229 | } | ||
| 6230 | |||
| 6231 | ✗ | if(!write_deprecated_section_cversion(s_version,f)) | |
| 6232 | { | ||
| 6233 | ✗ | pack_fclose(f); | |
| 6234 | ✗ | return false; | |
| 6235 | } | ||
| 6236 | |||
| 6237 | ✗ | if(savefrom.write(f)) | |
| 6238 | { | ||
| 6239 | ✗ | pack_fclose(f); | |
| 6240 | ✗ | return false; | |
| 6241 | } | ||
| 6242 | |||
| 6243 | ✗ | pack_fclose(f); | |
| 6244 | ✗ | return true; | |
| 6245 | ✗ | } | |
| 6246 | |||
| 6247 | ✗ | bool load_subscreen(const char *path, ZCSubscreen& loadto) | |
| 6248 | { | ||
| 6249 | //open the file | ||
| 6250 | ✗ | PACKFILE *f=pack_fopen_password(path,F_READ, ""); | |
| 6251 | |||
| 6252 | ✗ | if(!f) | |
| 6253 | ✗ | return false; | |
| 6254 | |||
| 6255 | dword section_id; | ||
| 6256 | dword s_version; | ||
| 6257 | |||
| 6258 | ✗ | if(!p_mgetl(§ion_id,f)) | |
| 6259 | { | ||
| 6260 | ✗ | pack_fclose(f); | |
| 6261 | ✗ | return false; | |
| 6262 | } | ||
| 6263 | |||
| 6264 | ✗ | if(section_id!=ID_SUBSCREEN) | |
| 6265 | { | ||
| 6266 | ✗ | pack_fclose(f); | |
| 6267 | ✗ | return false; | |
| 6268 | } | ||
| 6269 | |||
| 6270 | ✗ | if(!p_igetw(&s_version,f)) | |
| 6271 | { | ||
| 6272 | ✗ | pack_fclose(f); | |
| 6273 | ✗ | return false; | |
| 6274 | } | ||
| 6275 | |||
| 6276 | ✗ | if(!read_deprecated_section_cversion(f)) | |
| 6277 | { | ||
| 6278 | ✗ | pack_fclose(f); | |
| 6279 | ✗ | return false; | |
| 6280 | } | ||
| 6281 | |||
| 6282 | ✗ | if(s_version < 8) | |
| 6283 | { | ||
| 6284 | subscreen_group g; | ||
| 6285 | ✗ | memset(&g,0,sizeof(subscreen_group)); | |
| 6286 | ✗ | if(read_one_old_subscreen(f,&g,s_version)!=0) | |
| 6287 | { | ||
| 6288 | ✗ | pack_fclose(f); | |
| 6289 | ✗ | return false; | |
| 6290 | } | ||
| 6291 | ✗ | if(g.ss_type != loadto.sub_type) | |
| 6292 | { | ||
| 6293 | ✗ | pack_fclose(f); | |
| 6294 | ✗ | displayinfo("Failure!",fmt::format("Found subscreen type '{}', expecting type '{}'", | |
| 6295 | ✗ | subscr_names[g.ss_type], subscr_names[loadto.sub_type])); | |
| 6296 | ✗ | return false; | |
| 6297 | } | ||
| 6298 | ✗ | loadto.clear(); | |
| 6299 | ✗ | if(g.objects[0].type != ssoNULL) | |
| 6300 | ✗ | loadto.load_old(g); | |
| 6301 | ✗ | } | |
| 6302 | else | ||
| 6303 | { | ||
| 6304 | ✗ | ZCSubscreen tmp = ZCSubscreen(); | |
| 6305 | ✗ | if (tmp.read(f, s_version)) | |
| 6306 | { | ||
| 6307 | ✗ | pack_fclose(f); | |
| 6308 | ✗ | return false; | |
| 6309 | } | ||
| 6310 | ✗ | if(tmp.sub_type != loadto.sub_type) | |
| 6311 | { | ||
| 6312 | ✗ | pack_fclose(f); | |
| 6313 | ✗ | displayinfo("Failure!",fmt::format("Found subscreen type '{}', expecting type '{}'", | |
| 6314 | ✗ | subscr_names[tmp.sub_type], subscr_names[loadto.sub_type])); | |
| 6315 | ✗ | return false; | |
| 6316 | } | ||
| 6317 | ✗ | loadto.clear(); | |
| 6318 | ✗ | loadto = tmp; | |
| 6319 | ✗ | } | |
| 6320 | |||
| 6321 | ✗ | pack_fclose(f); | |
| 6322 | ✗ | return true; | |
| 6323 | ✗ | } | |
| 6324 | |||
| 6325 | ✗ | bool setMapCount2(int32_t c) | |
| 6326 | { | ||
| 6327 | ✗ | int32_t oldmapcount=map_count; | |
| 6328 | ✗ | int32_t cur_map=Map.getCurrMap(); | |
| 6329 | |||
| 6330 | ✗ | bound(c,1,MAXMAPS); | |
| 6331 | ✗ | map_count=c; | |
| 6332 | |||
| 6333 | try | ||
| 6334 | { | ||
| 6335 | ✗ | TheMaps.resize(c*MAPSCRS); | |
| 6336 | ✗ | Map.force_refr_pointer(); | |
| 6337 | ✗ | map_autolayers.resize(c*6); | |
| 6338 | ✗ | } | |
| 6339 | catch(...) | ||
| 6340 | { | ||
| 6341 | ✗ | jwin_alert("Error","Failed to change map count.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 6342 | ✗ | return false; | |
| 6343 | ✗ | } | |
| 6344 | |||
| 6345 | ✗ | bound(cur_map,0,c-1); | |
| 6346 | ✗ | if(map_count>oldmapcount) | |
| 6347 | { | ||
| 6348 | ✗ | for(int32_t mc=oldmapcount; mc<map_count; mc++) | |
| 6349 | { | ||
| 6350 | ✗ | Map.setCurrMap(mc); | |
| 6351 | |||
| 6352 | ✗ | for(int32_t ms=0; ms<MAPSCRS; ms++) | |
| 6353 | { | ||
| 6354 | ✗ | Map.clearscr(ms); | |
| 6355 | ✗ | } | |
| 6356 | ✗ | } | |
| 6357 | ✗ | Map.setCurrMap(cur_map); | |
| 6358 | ✗ | } | |
| 6359 | else | ||
| 6360 | { | ||
| 6361 | ✗ | Map.setCurrMap(cur_map); | |
| 6362 | ✗ | if(!layers_valid(Map.CurrScr())) | |
| 6363 | ✗ | fix_layers(Map.CurrScr(), false); | |
| 6364 | |||
| 6365 | ✗ | for(int32_t i=0; i<MAXDMAPS; i++) | |
| 6366 | { | ||
| 6367 | ✗ | if(DMaps[i].map>=map_count) | |
| 6368 | { | ||
| 6369 | ✗ | DMaps[i].map=map_count-1; | |
| 6370 | ✗ | } | |
| 6371 | ✗ | } | |
| 6372 | } | ||
| 6373 | |||
| 6374 | ✗ | return true; | |
| 6375 | ✗ | } | |
| 6376 | |||
| 6377 | extern BITMAP *bmap; | ||
| 6378 | |||
| 6379 | static bool loading_file_new = false; | ||
| 6380 | ✗ | int32_t init_quest(std::string tileset_path) | |
| 6381 | { | ||
| 6382 | ✗ | if (tileset_path.empty()) | |
| 6383 | ✗ | tileset_path = DEFAULT_TILESET; | |
| 6384 | |||
| 6385 | ✗ | loading_file_new = true; | |
| 6386 | ✗ | load_quest(tileset_path.c_str()); | |
| 6387 | ✗ | loading_file_new = false; | |
| 6388 | |||
| 6389 | ✗ | set_window_title("ZC Editor - Untitled Quest"); | |
| 6390 | ✗ | zinit.last_map = 0; | |
| 6391 | ✗ | zinit.last_screen = 0; | |
| 6392 | |||
| 6393 | ✗ | if(bmap != NULL) | |
| 6394 | { | ||
| 6395 | ✗ | destroy_bitmap(bmap); | |
| 6396 | ✗ | bmap=NULL; | |
| 6397 | ✗ | } | |
| 6398 | |||
| 6399 | ✗ | return 0; | |
| 6400 | } | ||
| 6401 | |||
| 6402 | ✗ | void set_questpwd(std::string_view pwd, bool use_keyfile) | |
| 6403 | { | ||
| 6404 | ✗ | header.use_keyfile=use_keyfile; | |
| 6405 | |||
| 6406 | // string_view actually has some quirks that make it less than ideal here. | ||
| 6407 | // It'd probably be best to replace it, but this works for now. | ||
| 6408 | ✗ | memset(header.password, 0, 256); | |
| 6409 | ✗ | strcpy(header.password, pwd.data()); | |
| 6410 | ✗ | header.dirty_password=true; | |
| 6411 | |||
| 6412 | cvs_MD5Context ctx; | ||
| 6413 | ✗ | cvs_MD5Init(&ctx); | |
| 6414 | ✗ | cvs_MD5Update(&ctx, (const uint8_t*)header.password, strlen(header.password)); | |
| 6415 | ✗ | cvs_MD5Final(header.pwd_hash, &ctx); | |
| 6416 | ✗ | } | |
| 6417 | |||
| 6418 | |||
| 6419 | ✗ | bool is_null_pwd_hash(uint8_t *pwd_hash) | |
| 6420 | { | ||
| 6421 | cvs_MD5Context ctx; | ||
| 6422 | uint8_t md5sum[16]; | ||
| 6423 | ✗ | char pwd[2]=""; | |
| 6424 | |||
| 6425 | ✗ | cvs_MD5Init(&ctx); | |
| 6426 | ✗ | cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd)); | |
| 6427 | ✗ | cvs_MD5Final(md5sum, &ctx); | |
| 6428 | |||
| 6429 | ✗ | return (memcmp(md5sum,pwd_hash,16)==0); | |
| 6430 | } | ||
| 6431 | |||
| 6432 | static DIALOG pwd_dlg[] = | ||
| 6433 | { | ||
| 6434 | /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */ | ||
| 6435 | { jwin_win_proc, 0, 0, 224+22+1, 88+10+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "Requires Authorization", NULL, NULL }, | ||
| 6436 | { jwin_text_proc, 16, 28, 96, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "File name:", NULL, NULL }, | ||
| 6437 | // 2 (filename) | ||
| 6438 | { jwin_text_proc, 72, 28, 128, 8, vc(11), vc(1), 0, 0, 24, 0, NULL, NULL, NULL }, | ||
| 6439 | { jwin_text_proc, 16, 38, 0, 8, vc(15), vc(1), 0, 0, 0, 0, (void *) "Challenge:", NULL, NULL }, | ||
| 6440 | // 4 (challenge hash) | ||
| 6441 | { jwin_text_proc, 72, 38, 0, 8, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL }, | ||
| 6442 | { jwin_text_proc, 16, 42+10, 96, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Password:", NULL, NULL }, | ||
| 6443 | // 6 (password) | ||
| 6444 | { jwin_edit_proc, 72, 38+10, 120+39, 16, vc(12), vc(1), 0, 0, 255, 0, NULL, NULL, NULL }, | ||
| 6445 | { jwin_button_proc, 42, 62+10, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL }, | ||
| 6446 | { jwin_button_proc, 122, 62+10, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL }, | ||
| 6447 | { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, | ||
| 6448 | { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } | ||
| 6449 | }; | ||
| 6450 | |||
| 6451 | ✗ | int32_t reverse_string(char* str) | |
| 6452 | { | ||
| 6453 | |||
| 6454 | ✗ | if(NULL==str) | |
| 6455 | { | ||
| 6456 | ✗ | return -1; //no string | |
| 6457 | } | ||
| 6458 | |||
| 6459 | ✗ | int32_t l=(int32_t)strlen(str)-1; //get the string length | |
| 6460 | |||
| 6461 | ✗ | if(1==l) | |
| 6462 | { | ||
| 6463 | ✗ | return 1; | |
| 6464 | } | ||
| 6465 | |||
| 6466 | char c; | ||
| 6467 | |||
| 6468 | ✗ | for(int32_t x=0; x < l; x++,l--) | |
| 6469 | { | ||
| 6470 | ✗ | c = str[x]; | |
| 6471 | ✗ | str[x] = str[l]; | |
| 6472 | ✗ | str[l] = c; | |
| 6473 | ✗ | } | |
| 6474 | |||
| 6475 | ✗ | return 0; | |
| 6476 | ✗ | } | |
| 6477 | |||
| 6478 | #ifdef __GNUC__ | ||
| 6479 | #pragma GCC diagnostic push | ||
| 6480 | #pragma GCC diagnostic ignored "-Wunreachable-code" | ||
| 6481 | #endif | ||
| 6482 | |||
| 6483 | 11 | int32_t quest_access(const char *filename, zquestheader *hdr) | |
| 6484 | { | ||
| 6485 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (is_headless()) |
| 6486 | 11 | return 1; | |
| 6487 | |||
| 6488 | #ifdef __EMSCRIPTEN__ | ||
| 6489 | return 1; | ||
| 6490 | #endif | ||
| 6491 | |||
| 6492 | //Protection against compiling a release version with password protection off. | ||
| 6493 | static bool passguard = false; | ||
| 6494 | |||
| 6495 | #if ( !(defined _DEBUG) || (defined _RELEASE || defined NDEBUG || defined _NDEBUG) ) | ||
| 6496 | #define MUST_HAVE_PASSWORD | ||
| 6497 | ✗ | passguard = true; | |
| 6498 | #endif | ||
| 6499 | |||
| 6500 | #if ( !(defined MUST_HAVE_PASSWORD) || defined _NPASS ) | ||
| 6501 | #if (defined _MSC_VER || defined _NPASS) | ||
| 6502 | return 1; | ||
| 6503 | #endif | ||
| 6504 | #endif | ||
| 6505 | ✗ | if(devpwd()) return 1; | |
| 6506 | |||
| 6507 | char hash_string[33]; | ||
| 6508 | |||
| 6509 | ✗ | if((get_debug() && (!(CHECK_CTRL_CMD))) || is_null_pwd_hash(hdr->pwd_hash)) | |
| 6510 | { | ||
| 6511 | ✗ | return 1; | |
| 6512 | } | ||
| 6513 | |||
| 6514 | ✗ | if(check_keyfiles(filename, {KEYFILE_MASTER,KEYFILE_ZPWD}, hdr)) | |
| 6515 | ✗ | return true; | |
| 6516 | |||
| 6517 | ✗ | pwd_dlg[0].dp2=get_zc_font(font_lfont); | |
| 6518 | ✗ | pwd_dlg[2].dp=get_filename(filename); | |
| 6519 | cvs_MD5Context ctx; | ||
| 6520 | ✗ | uint8_t md5sum[16]={0}; | |
| 6521 | ✗ | char response[33]=""; | |
| 6522 | ✗ | char prompt[256]=""; | |
| 6523 | |||
| 6524 | ✗ | memcpy(md5sum, hdr->pwd_hash, 16); | |
| 6525 | |||
| 6526 | ✗ | for(int32_t i=0; i<300; ++i) | |
| 6527 | { | ||
| 6528 | ✗ | for(int32_t j=0; j<16; ++j) | |
| 6529 | { | ||
| 6530 | ✗ | sprintf(response+j*2, "%02x", md5sum[j]); | |
| 6531 | ✗ | } | |
| 6532 | |||
| 6533 | ✗ | if(i&1) | |
| 6534 | { | ||
| 6535 | ✗ | reverse_string(response); | |
| 6536 | ✗ | } | |
| 6537 | |||
| 6538 | ✗ | if(i==149) | |
| 6539 | { | ||
| 6540 | ✗ | strcpy(hash_string, response); | |
| 6541 | ✗ | } | |
| 6542 | |||
| 6543 | ✗ | cvs_MD5Init(&ctx); | |
| 6544 | ✗ | cvs_MD5Update(&ctx, (const uint8_t*)response, (unsigned)strlen(response)); | |
| 6545 | ✗ | cvs_MD5Final(md5sum, &ctx); | |
| 6546 | ✗ | } | |
| 6547 | |||
| 6548 | ✗ | pwd_dlg[4].dp=hash_string; | |
| 6549 | |||
| 6550 | ✗ | if(get_debug() && (CHECK_CTRL_CMD)) //...what is this doing? | |
| 6551 | { | ||
| 6552 | ✗ | sprintf(prompt,"%s",response); | |
| 6553 | ✗ | } | |
| 6554 | |||
| 6555 | ✗ | pwd_dlg[6].dp=prompt; | |
| 6556 | |||
| 6557 | ✗ | large_dialog(pwd_dlg); | |
| 6558 | |||
| 6559 | ✗ | int32_t cancel = do_zqdialog(pwd_dlg,6); | |
| 6560 | |||
| 6561 | ✗ | if(cancel == 8) | |
| 6562 | ✗ | return 2; | |
| 6563 | |||
| 6564 | ✗ | bool ret=check_questpwd(hdr, prompt); | |
| 6565 | |||
| 6566 | ✗ | if(!ret) | |
| 6567 | { | ||
| 6568 | ✗ | ret=(strcmp(response,prompt)==0); | |
| 6569 | ✗ | } | |
| 6570 | ✗ | return ret ? 1 : 0; | |
| 6571 | 11 | } | |
| 6572 | |||
| 6573 | void set_rules(byte* newrules); | ||
| 6574 | 11 | void popup_bugfix_dlg(const char* cfg) | |
| 6575 | { | ||
| 6576 | 11 | bool dont_show_again = zc_get_config("zquest",cfg,0); | |
| 6577 |
2/4✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
|
11 | if(!dont_show_again && hasCompatRulesEnabled()) |
| 6578 | { | ||
| 6579 |
2/4✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
33 | AlertDialog("Apply New Bugfixes", |
| 6580 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | "New bugfixes found that can be applied to this quest!" |
| 6581 | "\nWould you like to apply them?" | ||
| 6582 | "\n(Applies 'Bugfix' rule template, un-checking compat rules)", | ||
| 6583 | 11 | [&](bool ret,bool dsa) | |
| 6584 | { | ||
| 6585 | ✗ | if(ret) | |
| 6586 | { | ||
| 6587 | ✗ | applyRuleTemplate(ruletemplateFixCompat); | |
| 6588 | ✗ | } | |
| 6589 | ✗ | if(dsa) | |
| 6590 | { | ||
| 6591 | ✗ | zc_set_config("zquest",cfg,1); | |
| 6592 | ✗ | } | |
| 6593 | ✗ | }, | |
| 6594 |
2/4✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
11 | "Yes","No", |
| 6595 | 0,false, //timeout - none | ||
| 6596 | true //"Don't show this again" | ||
| 6597 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | ).show(); |
| 6598 | 11 | } | |
| 6599 | 11 | } | |
| 6600 | |||
| 6601 | #ifdef __GNUC__ | ||
| 6602 | #pragma GCC diagnostic pop | ||
| 6603 | #endif | ||
| 6604 | |||
| 6605 | 11 | int32_t load_quest(const char *filename, bool show_progress) | |
| 6606 | { | ||
| 6607 | char buf[2048]; | ||
| 6608 | byte skip_flags[4]; | ||
| 6609 | |||
| 6610 | 11 | dword tileset_flags = 0; | |
| 6611 |
2/2✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
|
55 | for(int32_t i=0; i<4; ++i) |
| 6612 | { | ||
| 6613 | 44 | skip_flags[i]=0; | |
| 6614 | 44 | } | |
| 6615 |
2/2✓ Branch 0 taken 7623 times.
✓ Branch 1 taken 11 times.
|
7634 | for(int32_t i=0; i<qr_MAX; i++) |
| 6616 | 7623 | set_qr(i,0); | |
| 6617 | 11 | int32_t ret=loadquest(filename,&header,&QMisc,customtunes,show_progress,skip_flags,1,true,0,tileset_flags); | |
| 6618 | |||
| 6619 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if(ret!=qe_OK) |
| 6620 | { | ||
| 6621 | ✗ | init_quest(DEFAULT_TILESET); | |
| 6622 | ✗ | } | |
| 6623 | else | ||
| 6624 | { | ||
| 6625 | 11 | int32_t accessret = quest_access(filename, &header); | |
| 6626 | |||
| 6627 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if(accessret != 1) |
| 6628 | { | ||
| 6629 | ✗ | init_quest(DEFAULT_TILESET); | |
| 6630 | |||
| 6631 | ✗ | if(accessret == 0) | |
| 6632 | ✗ | ret=qe_pwd; | |
| 6633 | else | ||
| 6634 | ✗ | ret=qe_cancel; | |
| 6635 | ✗ | } | |
| 6636 | else | ||
| 6637 | { | ||
| 6638 | 11 | Map.clear(); | |
| 6639 | 11 | Map.setCurrMap(vbound(zinit.last_map,0,map_count-1)); | |
| 6640 | 11 | Map.setCurrScr(zinit.last_screen); | |
| 6641 | |||
| 6642 |
2/4✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
11 | std::string qst_cfg_header = qst_cfg_header_from_path(filepath); |
| 6643 |
2/4✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
11 | Map.setViewSize(zc_get_config(qst_cfg_header.c_str(), "zoom_num_screens", 1)); |
| 6644 | |||
| 6645 | extern int32_t current_mappage; | ||
| 6646 | 11 | current_mappage = 0; | |
| 6647 | 11 | bool found_default = false; | |
| 6648 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 83 times.
|
92 | for(int q = 0; q < MAX_MAPPAGE_BTNS; ++q) |
| 6649 | { | ||
| 6650 | 83 | auto &pg = map_page[q]; | |
| 6651 |
4/4✓ Branch 0 taken 11 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2 times.
|
83 | if(pg.map == Map.getCurrMap() && pg.screen == Map.getCurrScr()) |
| 6652 | { | ||
| 6653 | 2 | current_mappage = q; | |
| 6654 | 2 | break; | |
| 6655 | } | ||
| 6656 |
4/8✓ Branch 0 taken 9 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
81 | else if(found_default || pg.map > 1 || (pg.map == 1 && pg.screen > 0)) |
| 6657 | 72 | continue; | |
| 6658 | else | ||
| 6659 | { | ||
| 6660 | 9 | current_mappage = q; | |
| 6661 | 9 | found_default = true; | |
| 6662 | } | ||
| 6663 | 9 | } | |
| 6664 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | refresh(rALL); |
| 6665 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | refresh_pal(); |
| 6666 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | set_rules(quest_rules); |
| 6667 | 11 | saved = true; | |
| 6668 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
11 | if(!(loading_file_new && zc_get_config("zquest","auto_filenew_bugfixes",1))) |
| 6669 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | popup_bugfix_dlg("dsa_compatrule"); |
| 6670 | |||
| 6671 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if(bmap != NULL) |
| 6672 | { | ||
| 6673 | ✗ | destroy_bitmap(bmap); | |
| 6674 | ✗ | bmap=NULL; | |
| 6675 | ✗ | } | |
| 6676 | |||
| 6677 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if (show_progress) |
| 6678 | { | ||
| 6679 | ✗ | sprintf(buf,"ZC Editor - [%s]", get_filename(filename)); | |
| 6680 | ✗ | set_window_title(buf); | |
| 6681 | ✗ | } | |
| 6682 | 11 | } | |
| 6683 | } | ||
| 6684 | |||
| 6685 | 11 | Map.ClearCommandHistory(); | |
| 6686 | |||
| 6687 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (!is_headless()) |
| 6688 | { | ||
| 6689 | void load_size_poses(); | ||
| 6690 | ✗ | load_size_poses(); | |
| 6691 | ✗ | } | |
| 6692 | |||
| 6693 | 11 | return ret; | |
| 6694 | ✗ | } | |
| 6695 | |||
| 6696 | ✗ | int32_t load_tileset(const char *filename, dword tsetflags) | |
| 6697 | { | ||
| 6698 | byte skip_flags[4]; | ||
| 6699 | |||
| 6700 | ✗ | for(int32_t i=0; i<4; ++i) | |
| 6701 | ✗ | skip_flags[i]=0; | |
| 6702 | ✗ | for(int32_t i=0; i<qr_MAX; i++) | |
| 6703 | ✗ | set_qr(i,0); | |
| 6704 | ✗ | int32_t ret=loadquest(filename,&header,&QMisc,customtunes,true,skip_flags,1,true,0,tsetflags); | |
| 6705 | |||
| 6706 | ✗ | if(ret!=qe_OK) | |
| 6707 | ✗ | init_quest(DEFAULT_TILESET); | |
| 6708 | else | ||
| 6709 | { | ||
| 6710 | ✗ | if(tsetflags & TILESET_BUGFIX) | |
| 6711 | ✗ | applyRuleTemplate(ruletemplateFixCompat); | |
| 6712 | |||
| 6713 | ✗ | int32_t accessret = quest_access(filename, &header); | |
| 6714 | |||
| 6715 | ✗ | if(accessret != 1) | |
| 6716 | { | ||
| 6717 | ✗ | init_quest(DEFAULT_TILESET); | |
| 6718 | |||
| 6719 | ✗ | if(accessret == 0) | |
| 6720 | ✗ | ret=qe_pwd; | |
| 6721 | else | ||
| 6722 | ✗ | ret=qe_cancel; | |
| 6723 | ✗ | } | |
| 6724 | else | ||
| 6725 | { | ||
| 6726 | ✗ | Map.clear(); | |
| 6727 | ✗ | Map.setCurrMap(vbound(zinit.last_map,0,map_count-1)); | |
| 6728 | ✗ | Map.setCurrScr(zinit.last_screen); | |
| 6729 | extern int32_t current_mappage; | ||
| 6730 | ✗ | current_mappage = 0; | |
| 6731 | ✗ | bool found_default = false; | |
| 6732 | ✗ | for(int q = 0; q < MAX_MAPPAGE_BTNS; ++q) | |
| 6733 | { | ||
| 6734 | ✗ | auto &pg = map_page[q]; | |
| 6735 | ✗ | if(pg.map == Map.getCurrMap() && pg.screen == Map.getCurrScr()) | |
| 6736 | { | ||
| 6737 | ✗ | current_mappage = q; | |
| 6738 | ✗ | break; | |
| 6739 | } | ||
| 6740 | ✗ | else if(found_default || pg.map > 1 || (pg.map == 1 && pg.screen > 0)) | |
| 6741 | ✗ | continue; | |
| 6742 | else | ||
| 6743 | { | ||
| 6744 | ✗ | current_mappage = q; | |
| 6745 | ✗ | found_default = true; | |
| 6746 | } | ||
| 6747 | ✗ | } | |
| 6748 | ✗ | refresh(rALL); | |
| 6749 | ✗ | refresh_pal(); | |
| 6750 | ✗ | set_rules(quest_rules); | |
| 6751 | |||
| 6752 | ✗ | if(bmap != NULL) | |
| 6753 | { | ||
| 6754 | ✗ | destroy_bitmap(bmap); | |
| 6755 | ✗ | bmap=NULL; | |
| 6756 | ✗ | } | |
| 6757 | |||
| 6758 | ✗ | set_window_title("ZC Editor - Untitled Quest"); | |
| 6759 | ✗ | first_save = saved = false; | |
| 6760 | ✗ | memset(filepath,0,255); | |
| 6761 | ✗ | memset(temppath,0,255); | |
| 6762 | } | ||
| 6763 | } | ||
| 6764 | |||
| 6765 | ✗ | Map.ClearCommandHistory(); | |
| 6766 | |||
| 6767 | ✗ | return ret; | |
| 6768 | ✗ | } | |
| 6769 | |||
| 6770 | 130 | bool write_midi(MIDI *m,PACKFILE *f) | |
| 6771 | { | ||
| 6772 | int32_t c; | ||
| 6773 | |||
| 6774 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
|
130 | if(!p_mputw(m->divisions,f)) return false; |
| 6775 | |||
| 6776 |
2/2✓ Branch 0 taken 4160 times.
✓ Branch 1 taken 130 times.
|
4290 | for(c=0; c<MIDI_TRACKS; c++) |
| 6777 | { | ||
| 6778 |
1/2✓ Branch 0 taken 4160 times.
✗ Branch 1 not taken.
|
4160 | if(!p_mputl(m->track[c].len,f)) return false; |
| 6779 | |||
| 6780 |
2/2✓ Branch 0 taken 2896 times.
✓ Branch 1 taken 1264 times.
|
4160 | if(m->track[c].len > 0) |
| 6781 | { | ||
| 6782 |
1/2✓ Branch 0 taken 1264 times.
✗ Branch 1 not taken.
|
1264 | if(!pfwrite(m->track[c].data,m->track[c].len,f)) |
| 6783 | ✗ | return false; | |
| 6784 | 1264 | } | |
| 6785 | 4160 | } | |
| 6786 | |||
| 6787 | 130 | return true; | |
| 6788 | 130 | } | |
| 6789 | |||
| 6790 | 9 | int32_t writeheader(PACKFILE *f, zquestheader *Header) | |
| 6791 | { | ||
| 6792 | 9 | dword section_id=ID_HEADER; | |
| 6793 | 9 | dword section_version=V_HEADER; | |
| 6794 | 9 | dword section_size=0; | |
| 6795 | |||
| 6796 | //file header string | ||
| 6797 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!pfwrite(Header->id_str,sizeof(Header->id_str),f)) |
| 6798 | { | ||
| 6799 | ✗ | new_return(1); | |
| 6800 | } | ||
| 6801 | |||
| 6802 | //section id | ||
| 6803 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 6804 | { | ||
| 6805 | ✗ | new_return(2); | |
| 6806 | } | ||
| 6807 | |||
| 6808 | //section version info | ||
| 6809 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 6810 | { | ||
| 6811 | ✗ | new_return(3); | |
| 6812 | } | ||
| 6813 | |||
| 6814 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 6815 | { | ||
| 6816 | ✗ | new_return(4); | |
| 6817 | } | ||
| 6818 | |||
| 6819 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 6820 | { | ||
| 6821 | 18 | fake_pack_writing=(writecycle==0); | |
| 6822 | |||
| 6823 | //section size | ||
| 6824 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 6825 | { | ||
| 6826 | ✗ | new_return(5); | |
| 6827 | } | ||
| 6828 | |||
| 6829 | 18 | writesize=0; | |
| 6830 | |||
| 6831 | //finally... section data | ||
| 6832 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(Header->zelda_version,f)) |
| 6833 | { | ||
| 6834 | ✗ | new_return(6); | |
| 6835 | } | ||
| 6836 | |||
| 6837 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(Header->build,f)) |
| 6838 | { | ||
| 6839 | ✗ | new_return(7); | |
| 6840 | } | ||
| 6841 | |||
| 6842 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(Header->pwd_hash,sizeof(Header->pwd_hash),f)) |
| 6843 | { | ||
| 6844 | ✗ | new_return(8); | |
| 6845 | } | ||
| 6846 | |||
| 6847 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(Header->internal,f)) |
| 6848 | { | ||
| 6849 | ✗ | new_return(10); | |
| 6850 | } | ||
| 6851 | |||
| 6852 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(Header->quest_number,f)) |
| 6853 | { | ||
| 6854 | ✗ | new_return(11); | |
| 6855 | } | ||
| 6856 | |||
| 6857 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(Header->version,16,f)) |
| 6858 | { | ||
| 6859 | ✗ | new_return(12); | |
| 6860 | } | ||
| 6861 | |||
| 6862 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(Header->minver,16,f)) |
| 6863 | { | ||
| 6864 | ✗ | new_return(13); | |
| 6865 | } | ||
| 6866 | |||
| 6867 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(Header->title,sizeof(Header->title),f)) |
| 6868 | { | ||
| 6869 | ✗ | new_return(14); | |
| 6870 | } | ||
| 6871 | |||
| 6872 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(Header->author,sizeof(Header->author),f)) |
| 6873 | { | ||
| 6874 | ✗ | new_return(15); | |
| 6875 | } | ||
| 6876 | |||
| 6877 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(Header->use_keyfile,f)) |
| 6878 | { | ||
| 6879 | ✗ | new_return(16); | |
| 6880 | } | ||
| 6881 | |||
| 6882 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(Header->data_flags,sizeof(Header->data_flags),f)) |
| 6883 | { | ||
| 6884 | ✗ | new_return(17); | |
| 6885 | } | ||
| 6886 | |||
| 6887 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(Header->templatepath,sizeof(Header->templatepath),f)) |
| 6888 | { | ||
| 6889 | ✗ | new_return(19); | |
| 6890 | } | ||
| 6891 | |||
| 6892 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(0,f)) //why are we doing this? |
| 6893 | //this is for map count, it seems. -Z | ||
| 6894 | { | ||
| 6895 | ✗ | new_return(20); | |
| 6896 | } | ||
| 6897 | |||
| 6898 | 18 | auto version = getVersion(); | |
| 6899 | |||
| 6900 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(version.major,f)) |
| 6901 | { | ||
| 6902 | ✗ | new_return(21); | |
| 6903 | } | ||
| 6904 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(version.minor,f)) |
| 6905 | { | ||
| 6906 | ✗ | new_return(22); | |
| 6907 | } | ||
| 6908 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(version.patch,f)) |
| 6909 | { | ||
| 6910 | ✗ | new_return(23); | |
| 6911 | } | ||
| 6912 | // Fourth component is deprecated. | ||
| 6913 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(0,f)) |
| 6914 | { | ||
| 6915 | ✗ | new_return(24); | |
| 6916 | } | ||
| 6917 | |||
| 6918 | // Numerous prerelease stages is deprecated. | ||
| 6919 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(0,f)) |
| 6920 | { | ||
| 6921 | ✗ | new_return(25); | |
| 6922 | } | ||
| 6923 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(0,f)) |
| 6924 | { | ||
| 6925 | ✗ | new_return(26); | |
| 6926 | } | ||
| 6927 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(0,f)) |
| 6928 | { | ||
| 6929 | ✗ | new_return(27); | |
| 6930 | } | ||
| 6931 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(0,f)) |
| 6932 | { | ||
| 6933 | ✗ | new_return(28); | |
| 6934 | } | ||
| 6935 | |||
| 6936 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(BUILDTM_YEAR,f)) |
| 6937 | { | ||
| 6938 | ✗ | new_return(29); | |
| 6939 | } | ||
| 6940 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(BUILDTM_MONTH,f)) |
| 6941 | { | ||
| 6942 | ✗ | new_return(30); | |
| 6943 | } | ||
| 6944 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(BUILDTM_DAY,f)) |
| 6945 | { | ||
| 6946 | ✗ | new_return(31); | |
| 6947 | } | ||
| 6948 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(BUILDTM_HOUR,f)) |
| 6949 | { | ||
| 6950 | ✗ | new_return(32); | |
| 6951 | } | ||
| 6952 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(BUILDTM_MINUTE,f)) |
| 6953 | { | ||
| 6954 | ✗ | new_return(33); | |
| 6955 | } | ||
| 6956 | |||
| 6957 | // This is no longer set to anything. | ||
| 6958 | const char* tempsig[256]; | ||
| 6959 | 18 | memset(tempsig, 0, 256); | |
| 6960 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(&tempsig,256,f)) |
| 6961 | { | ||
| 6962 | ✗ | new_return(34); | |
| 6963 | } | ||
| 6964 | |||
| 6965 | char tempcompilersig[256]; | ||
| 6966 | 18 | memset(tempcompilersig, 0, 256); | |
| 6967 | 18 | strcpy(tempcompilersig, COMPILER_NAME); | |
| 6968 | |||
| 6969 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(&tempcompilersig,256,f)) |
| 6970 | { | ||
| 6971 | ✗ | new_return(35); | |
| 6972 | } | ||
| 6973 | |||
| 6974 | char tempcompilerversion[256]; | ||
| 6975 | 18 | memset(tempcompilerversion, 0, 256); | |
| 6976 | #ifdef _MSC_VER | ||
| 6977 | zc_itoa(_MSC_VER,tempcompilerversion,10); | ||
| 6978 | #else | ||
| 6979 | 18 | strcpy(tempcompilerversion, COMPILER_VERSION); | |
| 6980 | #endif | ||
| 6981 | |||
| 6982 | |||
| 6983 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(&tempcompilerversion,256,f)) |
| 6984 | { | ||
| 6985 | ✗ | new_return(36); | |
| 6986 | } | ||
| 6987 | |||
| 6988 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite("ZQuest Classic",1024,f)) |
| 6989 | { | ||
| 6990 | ✗ | new_return(37); | |
| 6991 | } | ||
| 6992 | |||
| 6993 | // V_ZC_COMPILERSIG - a deprecated version field. | ||
| 6994 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(1,f)) |
| 6995 | { | ||
| 6996 | ✗ | new_return(38); | |
| 6997 | } | ||
| 6998 | #ifdef _MSC_VER | ||
| 6999 | if(!p_iputl((_MSC_VER / 100),f)) | ||
| 7000 | { | ||
| 7001 | new_return(39); | ||
| 7002 | } | ||
| 7003 | #else | ||
| 7004 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(COMPILER_V_FIRST,f)) |
| 7005 | { | ||
| 7006 | ✗ | new_return(39); | |
| 7007 | } | ||
| 7008 | #endif | ||
| 7009 | |||
| 7010 | |||
| 7011 | |||
| 7012 | #ifdef _MSC_VER | ||
| 7013 | if(!p_iputl((_MSC_VER % 100),f)) | ||
| 7014 | { | ||
| 7015 | new_return(41); | ||
| 7016 | } | ||
| 7017 | #else | ||
| 7018 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(COMPILER_V_SECOND,f)) |
| 7019 | { | ||
| 7020 | ✗ | new_return(41); | |
| 7021 | } | ||
| 7022 | #endif | ||
| 7023 | |||
| 7024 | #ifdef _MSC_VER | ||
| 7025 | # if _MSC_VER >= 1400 | ||
| 7026 | if(!p_iputl((_MSC_FULL_VER % 100000),f)) | ||
| 7027 | { | ||
| 7028 | new_return(40); | ||
| 7029 | } | ||
| 7030 | # else | ||
| 7031 | if(!p_iputl((_MSC_FULL_VER % 10000),f)) | ||
| 7032 | { | ||
| 7033 | new_return(40); | ||
| 7034 | } | ||
| 7035 | #endif | ||
| 7036 | #else | ||
| 7037 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(COMPILER_V_THIRD,f)) |
| 7038 | { | ||
| 7039 | ✗ | new_return(40); | |
| 7040 | } | ||
| 7041 | #endif | ||
| 7042 | |||
| 7043 | #ifdef _MSC_VER | ||
| 7044 | if(!p_iputl((_MSC_BUILD),f)) | ||
| 7045 | { | ||
| 7046 | new_return(42); | ||
| 7047 | } | ||
| 7048 | #else | ||
| 7049 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(COMPILER_V_FOURTH,f)) |
| 7050 | { | ||
| 7051 | ✗ | new_return(42); | |
| 7052 | } | ||
| 7053 | #endif | ||
| 7054 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(0,f)) //was V_ZC_DEVSIG, no longer used |
| 7055 | { | ||
| 7056 | ✗ | new_return(43); | |
| 7057 | } | ||
| 7058 | |||
| 7059 | // Modules were removed (replaced by zinfo). | ||
| 7060 | char tempmodulename[1024]; | ||
| 7061 | 18 | memset(tempmodulename, 0, 1024); | |
| 7062 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(&tempmodulename,1024,f)) |
| 7063 | { | ||
| 7064 | ✗ | new_return(44); | |
| 7065 | } | ||
| 7066 | |||
| 7067 | char tempdate[256]; | ||
| 7068 | 18 | memset(tempdate, 0, 256); | |
| 7069 | 18 | strcpy(tempdate, __DATE__); | |
| 7070 | |||
| 7071 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(&tempdate,256,f)) |
| 7072 | { | ||
| 7073 | ✗ | new_return(45); | |
| 7074 | } | ||
| 7075 | char temptime[256]; | ||
| 7076 | 18 | memset(temptime, 0, 256); | |
| 7077 | 18 | strcpy(temptime, __TIME__); | |
| 7078 | |||
| 7079 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(&temptime,256,f)) |
| 7080 | { | ||
| 7081 | ✗ | new_return(46); | |
| 7082 | } | ||
| 7083 | |||
| 7084 | |||
| 7085 | char temptimezone[6]; | ||
| 7086 | 18 | memset(temptimezone, 0, 6); | |
| 7087 | 18 | strcpy(temptimezone, __TIMEZONE__); | |
| 7088 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(&temptimezone,6,f)) |
| 7089 | { | ||
| 7090 | ✗ | new_return(47); | |
| 7091 | } | ||
| 7092 | |||
| 7093 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(Header->external_zinfo ? 1 : 0, f)) |
| 7094 | { | ||
| 7095 | ✗ | new_return(48); | |
| 7096 | } | ||
| 7097 | |||
| 7098 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(isStableRelease() ? 0 : 1, f)) |
| 7099 | { | ||
| 7100 | ✗ | new_return(49); | |
| 7101 | } | ||
| 7102 | |||
| 7103 |
3/6✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
|
18 | if(!p_putcstr(version.version_string, f)) |
| 7104 | { | ||
| 7105 | ✗ | new_return(50); | |
| 7106 | } | ||
| 7107 | |||
| 7108 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 7109 | { | ||
| 7110 | 9 | section_size=writesize; | |
| 7111 | 9 | } | |
| 7112 | 18 | } | |
| 7113 | |||
| 7114 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 7115 | { | ||
| 7116 | char ebuf[80]; | ||
| 7117 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 7118 | ✗ | jwin_alert("Error: writeheader()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 7119 | ✗ | } | |
| 7120 | |||
| 7121 | 9 | new_return(0); | |
| 7122 | ✗ | } | |
| 7123 | |||
| 7124 | 9 | int32_t writerules(PACKFILE *f, zquestheader *Header) | |
| 7125 | { | ||
| 7126 | //these are here to bypass compiler warnings about unused arguments | ||
| 7127 | 9 | Header=Header; | |
| 7128 | |||
| 7129 | 9 | dword section_id=ID_RULES; | |
| 7130 | 9 | dword section_version=V_RULES; | |
| 7131 | 9 | dword section_size=0; | |
| 7132 | |||
| 7133 | //section id | ||
| 7134 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 7135 | { | ||
| 7136 | ✗ | new_return(1); | |
| 7137 | } | ||
| 7138 | |||
| 7139 | //section version info | ||
| 7140 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 7141 | { | ||
| 7142 | ✗ | new_return(2); | |
| 7143 | } | ||
| 7144 | |||
| 7145 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 7146 | { | ||
| 7147 | ✗ | new_return(3); | |
| 7148 | } | ||
| 7149 | |||
| 7150 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!p_iputl(V_COMPATRULE,f)) |
| 7151 | { | ||
| 7152 | ✗ | new_return(6); | |
| 7153 | } | ||
| 7154 | |||
| 7155 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 7156 | { | ||
| 7157 | 18 | fake_pack_writing=(writecycle==0); | |
| 7158 | |||
| 7159 | //section size | ||
| 7160 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 7161 | { | ||
| 7162 | ✗ | new_return(4); | |
| 7163 | } | ||
| 7164 | |||
| 7165 | 18 | writesize=0; | |
| 7166 | |||
| 7167 | //finally... section data | ||
| 7168 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(quest_rules,QUESTRULES_NEW_SIZE,f)) |
| 7169 | { | ||
| 7170 | ✗ | new_return(5); | |
| 7171 | } | ||
| 7172 | |||
| 7173 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 7174 | { | ||
| 7175 | 9 | section_size=writesize; | |
| 7176 | 9 | } | |
| 7177 | 18 | } | |
| 7178 | |||
| 7179 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 7180 | { | ||
| 7181 | char ebuf[80]; | ||
| 7182 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 7183 | ✗ | jwin_alert("Error: writerules()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 7184 | ✗ | } | |
| 7185 | |||
| 7186 | 9 | new_return(0); | |
| 7187 | } | ||
| 7188 | |||
| 7189 | |||
| 7190 | 9 | int32_t writedoorcombosets(PACKFILE *f, zquestheader *Header) | |
| 7191 | { | ||
| 7192 | //these are here to bypass compiler warnings about unused arguments | ||
| 7193 | 9 | Header=Header; | |
| 7194 | |||
| 7195 | 9 | dword section_id=ID_DOORS; | |
| 7196 | 9 | dword section_version=V_DOORS; | |
| 7197 | 9 | dword section_size=0; | |
| 7198 | |||
| 7199 | //section id | ||
| 7200 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 7201 | { | ||
| 7202 | ✗ | new_return(1); | |
| 7203 | } | ||
| 7204 | |||
| 7205 | //section version info | ||
| 7206 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 7207 | { | ||
| 7208 | ✗ | new_return(2); | |
| 7209 | } | ||
| 7210 | |||
| 7211 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 7212 | { | ||
| 7213 | ✗ | new_return(3); | |
| 7214 | } | ||
| 7215 | |||
| 7216 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 7217 | { | ||
| 7218 | 18 | fake_pack_writing=(writecycle==0); | |
| 7219 | |||
| 7220 | //section size | ||
| 7221 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 7222 | { | ||
| 7223 | ✗ | new_return(4); | |
| 7224 | } | ||
| 7225 | |||
| 7226 | 18 | writesize=0; | |
| 7227 | |||
| 7228 | //finally... section data | ||
| 7229 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(door_combo_set_count,f)) |
| 7230 | { | ||
| 7231 | ✗ | new_return(5); | |
| 7232 | } | ||
| 7233 | |||
| 7234 |
2/2✓ Branch 0 taken 320 times.
✓ Branch 1 taken 18 times.
|
338 | for(int32_t i=0; i<door_combo_set_count; i++) |
| 7235 | { | ||
| 7236 | //name | ||
| 7237 | char name[21]; | ||
| 7238 | 320 | memset(name, 21, (char)0); | |
| 7239 | 320 | strcpy(name, DoorComboSetNames[i].c_str()); | |
| 7240 |
1/2✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
|
320 | if(!pfwrite(name,sizeof(name),f)) |
| 7241 | { | ||
| 7242 | ✗ | new_return(6); | |
| 7243 | } | ||
| 7244 | |||
| 7245 | //up door | ||
| 7246 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 320 times.
|
3200 | for(int32_t j=0; j<9; j++) |
| 7247 | { | ||
| 7248 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 11520 times.
|
14400 | for(int32_t k=0; k<4; k++) |
| 7249 | { | ||
| 7250 |
1/2✓ Branch 0 taken 11520 times.
✗ Branch 1 not taken.
|
11520 | if(!p_iputw(DoorComboSets[i].doorcombo_u[j][k],f)) |
| 7251 | { | ||
| 7252 | ✗ | new_return(7); | |
| 7253 | } | ||
| 7254 | 11520 | } | |
| 7255 | 2880 | } | |
| 7256 | |||
| 7257 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 320 times.
|
3200 | for(int32_t j=0; j<9; j++) |
| 7258 | { | ||
| 7259 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 11520 times.
|
14400 | for(int32_t k=0; k<4; k++) |
| 7260 | { | ||
| 7261 |
1/2✓ Branch 0 taken 11520 times.
✗ Branch 1 not taken.
|
11520 | if(!p_putc(DoorComboSets[i].doorcset_u[j][k],f)) |
| 7262 | { | ||
| 7263 | ✗ | new_return(8); | |
| 7264 | } | ||
| 7265 | 11520 | } | |
| 7266 | 2880 | } | |
| 7267 | |||
| 7268 | //down door | ||
| 7269 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 320 times.
|
3200 | for(int32_t j=0; j<9; j++) |
| 7270 | { | ||
| 7271 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 11520 times.
|
14400 | for(int32_t k=0; k<4; k++) |
| 7272 | { | ||
| 7273 |
1/2✓ Branch 0 taken 11520 times.
✗ Branch 1 not taken.
|
11520 | if(!p_iputw(DoorComboSets[i].doorcombo_d[j][k],f)) |
| 7274 | { | ||
| 7275 | ✗ | new_return(9); | |
| 7276 | } | ||
| 7277 | 11520 | } | |
| 7278 | 2880 | } | |
| 7279 | |||
| 7280 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 320 times.
|
3200 | for(int32_t j=0; j<9; j++) |
| 7281 | { | ||
| 7282 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 11520 times.
|
14400 | for(int32_t k=0; k<4; k++) |
| 7283 | { | ||
| 7284 |
1/2✓ Branch 0 taken 11520 times.
✗ Branch 1 not taken.
|
11520 | if(!p_putc(DoorComboSets[i].doorcset_d[j][k],f)) |
| 7285 | { | ||
| 7286 | ✗ | new_return(10); | |
| 7287 | } | ||
| 7288 | 11520 | } | |
| 7289 | 2880 | } | |
| 7290 | |||
| 7291 | |||
| 7292 | //left door | ||
| 7293 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 320 times.
|
3200 | for(int32_t j=0; j<9; j++) |
| 7294 | { | ||
| 7295 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 17280 times.
|
20160 | for(int32_t k=0; k<6; k++) |
| 7296 | { | ||
| 7297 |
1/2✓ Branch 0 taken 17280 times.
✗ Branch 1 not taken.
|
17280 | if(!p_iputw(DoorComboSets[i].doorcombo_l[j][k],f)) |
| 7298 | |||
| 7299 | { | ||
| 7300 | ✗ | new_return(11); | |
| 7301 | } | ||
| 7302 | 17280 | } | |
| 7303 | 2880 | } | |
| 7304 | |||
| 7305 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 320 times.
|
3200 | for(int32_t j=0; j<9; j++) |
| 7306 | { | ||
| 7307 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 17280 times.
|
20160 | for(int32_t k=0; k<6; k++) |
| 7308 | { | ||
| 7309 |
1/2✓ Branch 0 taken 17280 times.
✗ Branch 1 not taken.
|
17280 | if(!p_putc(DoorComboSets[i].doorcset_l[j][k],f)) |
| 7310 | { | ||
| 7311 | ✗ | new_return(12); | |
| 7312 | } | ||
| 7313 | 17280 | } | |
| 7314 | 2880 | } | |
| 7315 | |||
| 7316 | //right door | ||
| 7317 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 320 times.
|
3200 | for(int32_t j=0; j<9; j++) |
| 7318 | { | ||
| 7319 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 17280 times.
|
20160 | for(int32_t k=0; k<6; k++) |
| 7320 | { | ||
| 7321 |
1/2✓ Branch 0 taken 17280 times.
✗ Branch 1 not taken.
|
17280 | if(!p_iputw(DoorComboSets[i].doorcombo_r[j][k],f)) |
| 7322 | { | ||
| 7323 | ✗ | new_return(13); | |
| 7324 | } | ||
| 7325 | 17280 | } | |
| 7326 | 2880 | } | |
| 7327 | |||
| 7328 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 320 times.
|
3200 | for(int32_t j=0; j<9; j++) |
| 7329 | { | ||
| 7330 |
2/2✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 17280 times.
|
20160 | for(int32_t k=0; k<6; k++) |
| 7331 | { | ||
| 7332 |
1/2✓ Branch 0 taken 17280 times.
✗ Branch 1 not taken.
|
17280 | if(!p_putc(DoorComboSets[i].doorcset_r[j][k],f)) |
| 7333 | { | ||
| 7334 | ✗ | new_return(14); | |
| 7335 | } | ||
| 7336 | 17280 | } | |
| 7337 | 2880 | } | |
| 7338 | |||
| 7339 | |||
| 7340 | //up bomb rubble | ||
| 7341 |
2/2✓ Branch 0 taken 640 times.
✓ Branch 1 taken 320 times.
|
960 | for(int32_t j=0; j<2; j++) |
| 7342 | { | ||
| 7343 |
1/2✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
|
640 | if(!p_iputw(DoorComboSets[i].bombdoorcombo_u[j],f)) |
| 7344 | { | ||
| 7345 | ✗ | new_return(15); | |
| 7346 | } | ||
| 7347 | 640 | } | |
| 7348 | |||
| 7349 |
2/2✓ Branch 0 taken 640 times.
✓ Branch 1 taken 320 times.
|
960 | for(int32_t j=0; j<2; j++) |
| 7350 | { | ||
| 7351 |
1/2✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
|
640 | if(!p_putc(DoorComboSets[i].bombdoorcset_u[j],f)) |
| 7352 | { | ||
| 7353 | ✗ | new_return(16); | |
| 7354 | } | ||
| 7355 | 640 | } | |
| 7356 | |||
| 7357 | //down bomb rubble | ||
| 7358 |
2/2✓ Branch 0 taken 640 times.
✓ Branch 1 taken 320 times.
|
960 | for(int32_t j=0; j<2; j++) |
| 7359 | { | ||
| 7360 |
1/2✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
|
640 | if(!p_iputw(DoorComboSets[i].bombdoorcombo_d[j],f)) |
| 7361 | { | ||
| 7362 | ✗ | new_return(17); | |
| 7363 | } | ||
| 7364 | 640 | } | |
| 7365 | |||
| 7366 |
2/2✓ Branch 0 taken 640 times.
✓ Branch 1 taken 320 times.
|
960 | for(int32_t j=0; j<2; j++) |
| 7367 | { | ||
| 7368 |
1/2✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
|
640 | if(!p_putc(DoorComboSets[i].bombdoorcset_d[j],f)) |
| 7369 | { | ||
| 7370 | ✗ | new_return(18); | |
| 7371 | } | ||
| 7372 | 640 | } | |
| 7373 | |||
| 7374 | //left bomb rubble | ||
| 7375 |
2/2✓ Branch 0 taken 960 times.
✓ Branch 1 taken 320 times.
|
1280 | for(int32_t j=0; j<3; j++) |
| 7376 | { | ||
| 7377 |
1/2✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
|
960 | if(!p_iputw(DoorComboSets[i].bombdoorcombo_l[j],f)) |
| 7378 | { | ||
| 7379 | ✗ | new_return(19); | |
| 7380 | } | ||
| 7381 | 960 | } | |
| 7382 | |||
| 7383 |
2/2✓ Branch 0 taken 960 times.
✓ Branch 1 taken 320 times.
|
1280 | for(int32_t j=0; j<3; j++) |
| 7384 | { | ||
| 7385 |
1/2✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
|
960 | if(!p_putc(DoorComboSets[i].bombdoorcset_l[j],f)) |
| 7386 | { | ||
| 7387 | ✗ | new_return(20); | |
| 7388 | } | ||
| 7389 | 960 | } | |
| 7390 | |||
| 7391 | //right bomb rubble | ||
| 7392 |
2/2✓ Branch 0 taken 960 times.
✓ Branch 1 taken 320 times.
|
1280 | for(int32_t j=0; j<3; j++) |
| 7393 | { | ||
| 7394 |
1/2✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
|
960 | if(!p_iputw(DoorComboSets[i].bombdoorcombo_r[j],f)) |
| 7395 | { | ||
| 7396 | ✗ | new_return(21); | |
| 7397 | } | ||
| 7398 | 960 | } | |
| 7399 | |||
| 7400 |
2/2✓ Branch 0 taken 960 times.
✓ Branch 1 taken 320 times.
|
1280 | for(int32_t j=0; j<3; j++) |
| 7401 | { | ||
| 7402 |
1/2✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
|
960 | if(!p_putc(DoorComboSets[i].bombdoorcset_r[j],f)) |
| 7403 | { | ||
| 7404 | ✗ | new_return(22); | |
| 7405 | } | ||
| 7406 | 960 | } | |
| 7407 | |||
| 7408 | //walkthrough stuff | ||
| 7409 |
2/2✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 320 times.
|
1600 | for(int32_t j=0; j<4; j++) |
| 7410 | { | ||
| 7411 |
1/2✓ Branch 0 taken 1280 times.
✗ Branch 1 not taken.
|
1280 | if(!p_iputw(DoorComboSets[i].walkthroughcombo[j],f)) |
| 7412 | { | ||
| 7413 | ✗ | new_return(23); | |
| 7414 | } | ||
| 7415 | 1280 | } | |
| 7416 | |||
| 7417 |
2/2✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 320 times.
|
1600 | for(int32_t j=0; j<4; j++) |
| 7418 | { | ||
| 7419 |
1/2✓ Branch 0 taken 1280 times.
✗ Branch 1 not taken.
|
1280 | if(!p_putc(DoorComboSets[i].walkthroughcset[j],f)) |
| 7420 | { | ||
| 7421 | ✗ | new_return(24); | |
| 7422 | } | ||
| 7423 | 1280 | } | |
| 7424 | |||
| 7425 | //flags | ||
| 7426 |
2/2✓ Branch 0 taken 640 times.
✓ Branch 1 taken 320 times.
|
960 | for(int32_t j=0; j<2; j++) |
| 7427 | { | ||
| 7428 |
1/2✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
|
640 | if(!p_putc(DoorComboSets[i].flags[j],f)) |
| 7429 | { | ||
| 7430 | ✗ | new_return(25); | |
| 7431 | } | ||
| 7432 | 640 | } | |
| 7433 | 320 | } | |
| 7434 | |||
| 7435 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 7436 | { | ||
| 7437 | 9 | section_size=writesize; | |
| 7438 | 9 | } | |
| 7439 | 18 | } | |
| 7440 | |||
| 7441 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 7442 | { | ||
| 7443 | char ebuf[80]; | ||
| 7444 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 7445 | ✗ | jwin_alert("Error: writedoorcombosets()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 7446 | ✗ | } | |
| 7447 | |||
| 7448 | 9 | new_return(0); | |
| 7449 | } | ||
| 7450 | |||
| 7451 | 9 | int32_t writedmaps(PACKFILE *f, word version, word build, word start_dmap, word max_dmaps) | |
| 7452 | { | ||
| 7453 | //these are here to bypass compiler warnings about unused arguments | ||
| 7454 | 9 | version=version; | |
| 7455 | 9 | build=build; | |
| 7456 | |||
| 7457 | 9 | word dmap_count=count_dmaps(); | |
| 7458 | 9 | dword section_id=ID_DMAPS; | |
| 7459 | 9 | dword section_version=V_DMAPS; | |
| 7460 | 9 | dword section_size=0; | |
| 7461 | |||
| 7462 | //section id | ||
| 7463 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 7464 | { | ||
| 7465 | ✗ | new_return(1); | |
| 7466 | } | ||
| 7467 | |||
| 7468 | //section version info | ||
| 7469 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 7470 | { | ||
| 7471 | ✗ | new_return(2); | |
| 7472 | } | ||
| 7473 | |||
| 7474 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 7475 | { | ||
| 7476 | ✗ | new_return(3); | |
| 7477 | } | ||
| 7478 | |||
| 7479 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 7480 | { | ||
| 7481 | 18 | fake_pack_writing=(writecycle==0); | |
| 7482 | |||
| 7483 | //section size | ||
| 7484 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 7485 | { | ||
| 7486 | ✗ | new_return(4); | |
| 7487 | } | ||
| 7488 | |||
| 7489 | 18 | writesize=0; | |
| 7490 | |||
| 7491 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | dmap_count=zc_min(dmap_count, max_dmaps); |
| 7492 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | dmap_count=zc_min(dmap_count, MAXDMAPS-start_dmap); |
| 7493 | |||
| 7494 | //finally... section data | ||
| 7495 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(dmap_count,f)) |
| 7496 | { | ||
| 7497 | ✗ | new_return(5); | |
| 7498 | } | ||
| 7499 | |||
| 7500 | |||
| 7501 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
|
9234 | for(int32_t i=start_dmap; i<start_dmap+dmap_count; i++) |
| 7502 | { | ||
| 7503 | 9216 | DMaps[i].validate_subscreens(); | |
| 7504 | |||
| 7505 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].map,f)) |
| 7506 | { | ||
| 7507 | ✗ | new_return(6); | |
| 7508 | } | ||
| 7509 | |||
| 7510 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(DMaps[i].level,f)) |
| 7511 | { | ||
| 7512 | ✗ | new_return(7); | |
| 7513 | } | ||
| 7514 | |||
| 7515 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].xoff,f)) |
| 7516 | { | ||
| 7517 | ✗ | new_return(8); | |
| 7518 | } | ||
| 7519 | |||
| 7520 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].compass,f)) |
| 7521 | { | ||
| 7522 | ✗ | new_return(9); | |
| 7523 | } | ||
| 7524 | |||
| 7525 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(DMaps[i].color,f)) |
| 7526 | { | ||
| 7527 | ✗ | new_return(10); | |
| 7528 | } | ||
| 7529 | |||
| 7530 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].midi,f)) |
| 7531 | { | ||
| 7532 | ✗ | new_return(11); | |
| 7533 | } | ||
| 7534 | |||
| 7535 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].cont,f)) |
| 7536 | { | ||
| 7537 | ✗ | new_return(12); | |
| 7538 | } | ||
| 7539 | |||
| 7540 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].type,f)) |
| 7541 | { | ||
| 7542 | ✗ | new_return(13); | |
| 7543 | } | ||
| 7544 | |||
| 7545 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
|
82944 | for(int32_t j=0; j<8; j++) |
| 7546 | { | ||
| 7547 |
1/2✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
|
73728 | if(!p_putc(DMaps[i].grid[j],f)) |
| 7548 | { | ||
| 7549 | ✗ | new_return(14); | |
| 7550 | } | ||
| 7551 | 73728 | } | |
| 7552 | |||
| 7553 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name)-1,f)) |
| 7554 | { | ||
| 7555 | ✗ | new_return(15); | |
| 7556 | } | ||
| 7557 | |||
| 7558 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putwstr(DMaps[i].title,f)) |
| 7559 | { | ||
| 7560 | ✗ | new_return(16); | |
| 7561 | } | ||
| 7562 | |||
| 7563 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro)-1,f)) |
| 7564 | { | ||
| 7565 | ✗ | new_return(17); | |
| 7566 | } | ||
| 7567 | |||
| 7568 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(DMaps[i].minimap_1_tile,f)) |
| 7569 | { | ||
| 7570 | ✗ | new_return(18); | |
| 7571 | } | ||
| 7572 | |||
| 7573 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].minimap_1_cset,f)) |
| 7574 | { | ||
| 7575 | ✗ | new_return(19); | |
| 7576 | } | ||
| 7577 | |||
| 7578 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(DMaps[i].minimap_2_tile,f)) |
| 7579 | { | ||
| 7580 | ✗ | new_return(20); | |
| 7581 | } | ||
| 7582 | |||
| 7583 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].minimap_2_cset,f)) |
| 7584 | { | ||
| 7585 | ✗ | new_return(21); | |
| 7586 | } | ||
| 7587 | |||
| 7588 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(DMaps[i].largemap_1_tile,f)) |
| 7589 | { | ||
| 7590 | ✗ | new_return(22); | |
| 7591 | } | ||
| 7592 | |||
| 7593 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].largemap_1_cset,f)) |
| 7594 | { | ||
| 7595 | ✗ | new_return(23); | |
| 7596 | } | ||
| 7597 | |||
| 7598 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(DMaps[i].largemap_2_tile,f)) |
| 7599 | { | ||
| 7600 | ✗ | new_return(24); | |
| 7601 | } | ||
| 7602 | |||
| 7603 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].largemap_2_cset,f)) |
| 7604 | { | ||
| 7605 | ✗ | new_return(25); | |
| 7606 | } | ||
| 7607 | |||
| 7608 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic)-1,f)) |
| 7609 | { | ||
| 7610 | ✗ | new_return(26); | |
| 7611 | } | ||
| 7612 | |||
| 7613 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].tmusictrack,f)) |
| 7614 | { | ||
| 7615 | ✗ | new_return(25); | |
| 7616 | } | ||
| 7617 | |||
| 7618 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].active_subscreen,f)) |
| 7619 | { | ||
| 7620 | ✗ | new_return(26); | |
| 7621 | } | ||
| 7622 | |||
| 7623 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].passive_subscreen,f)) |
| 7624 | { | ||
| 7625 | ✗ | new_return(27); | |
| 7626 | } | ||
| 7627 | |||
| 7628 | byte disabled[32]; | ||
| 7629 | 9216 | memset(disabled,0,32); | |
| 7630 | |||
| 7631 |
2/2✓ Branch 0 taken 2359296 times.
✓ Branch 1 taken 9216 times.
|
2368512 | for(int32_t j=0; j<MAXITEMS; j++) |
| 7632 | { | ||
| 7633 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2359296 times.
|
2359296 | if(DMaps[i].disableditems[j]) |
| 7634 | { | ||
| 7635 | ✗ | disabled[j/8] |= (1 << (j%8)); | |
| 7636 | ✗ | } | |
| 7637 | 2359296 | } | |
| 7638 | |||
| 7639 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!pfwrite(disabled,32,f)) |
| 7640 | { | ||
| 7641 | ✗ | new_return(28); | |
| 7642 | } | ||
| 7643 | |||
| 7644 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(DMaps[i].flags,f)) |
| 7645 | { | ||
| 7646 | ✗ | new_return(29); | |
| 7647 | } | ||
| 7648 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].sideview,f)) |
| 7649 | { | ||
| 7650 | ✗ | new_return(30); | |
| 7651 | } | ||
| 7652 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(DMaps[i].script,f)) |
| 7653 | { | ||
| 7654 | ✗ | new_return(31); | |
| 7655 | } | ||
| 7656 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
|
82944 | for ( int32_t q = 0; q < 8; q++ ) |
| 7657 | { | ||
| 7658 |
1/2✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
|
73728 | if(!p_iputl(DMaps[i].initD[q],f)) |
| 7659 | { | ||
| 7660 | ✗ | new_return(32); | |
| 7661 | } | ||
| 7662 | |||
| 7663 | 73728 | } | |
| 7664 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
|
82944 | for ( int32_t q = 0; q < 8; q++ ) |
| 7665 | { | ||
| 7666 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 4792320 times.
|
4866048 | for ( int32_t w = 0; w < 65; w++ ) |
| 7667 | { | ||
| 7668 |
1/2✓ Branch 0 taken 4792320 times.
✗ Branch 1 not taken.
|
4792320 | if (!p_putc(DMaps[i].initD_label[q][w],f)) |
| 7669 | { | ||
| 7670 | ✗ | new_return(33); | |
| 7671 | } | ||
| 7672 | 4792320 | } | |
| 7673 | 73728 | } | |
| 7674 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(DMaps[i].active_sub_script,f)) |
| 7675 | { | ||
| 7676 | ✗ | new_return(34); | |
| 7677 | } | ||
| 7678 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(DMaps[i].passive_sub_script,f)) |
| 7679 | { | ||
| 7680 | ✗ | new_return(35); | |
| 7681 | } | ||
| 7682 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
|
82944 | for(int32_t q = 0; q < 8; ++q) |
| 7683 | { | ||
| 7684 |
1/2✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
|
73728 | if(!p_iputl(DMaps[i].sub_initD[q],f)) |
| 7685 | { | ||
| 7686 | ✗ | new_return(36); | |
| 7687 | } | ||
| 7688 | 73728 | } | |
| 7689 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
|
82944 | for(int32_t q = 0; q < 8; ++q) |
| 7690 | { | ||
| 7691 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 4792320 times.
|
4866048 | for(int32_t w = 0; w < 65; ++w) |
| 7692 | { | ||
| 7693 |
1/2✓ Branch 0 taken 4792320 times.
✗ Branch 1 not taken.
|
4792320 | if(!p_putc(DMaps[i].sub_initD_label[q][w],f)) |
| 7694 | { | ||
| 7695 | ✗ | new_return(37); | |
| 7696 | } | ||
| 7697 | 4792320 | } | |
| 7698 | 73728 | } | |
| 7699 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(DMaps[i].onmap_script,f)) |
| 7700 | { | ||
| 7701 | ✗ | new_return(38); | |
| 7702 | } | ||
| 7703 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
|
82944 | for(int32_t q = 0; q < 8; ++q) |
| 7704 | { | ||
| 7705 |
1/2✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
|
73728 | if(!p_iputl(DMaps[i].onmap_initD[q],f)) |
| 7706 | { | ||
| 7707 | ✗ | new_return(39); | |
| 7708 | } | ||
| 7709 | 73728 | } | |
| 7710 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
|
82944 | for(int32_t q = 0; q < 8; ++q) |
| 7711 | { | ||
| 7712 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 4792320 times.
|
4866048 | for(int32_t w = 0; w < 65; ++w) |
| 7713 | { | ||
| 7714 |
1/2✓ Branch 0 taken 4792320 times.
✗ Branch 1 not taken.
|
4792320 | if(!p_putc(DMaps[i].onmap_initD_label[q][w],f)) |
| 7715 | { | ||
| 7716 | ✗ | new_return(40); | |
| 7717 | } | ||
| 7718 | 4792320 | } | |
| 7719 | 73728 | } | |
| 7720 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(DMaps[i].mirrorDMap,f)) |
| 7721 | { | ||
| 7722 | ✗ | new_return(41); | |
| 7723 | } | ||
| 7724 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(DMaps[i].tmusic_loop_start, f)) |
| 7725 | { | ||
| 7726 | ✗ | new_return(42); | |
| 7727 | } | ||
| 7728 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(DMaps[i].tmusic_loop_end, f)) |
| 7729 | { | ||
| 7730 | ✗ | new_return(43); | |
| 7731 | } | ||
| 7732 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(DMaps[i].tmusic_xfade_in, f)) |
| 7733 | { | ||
| 7734 | ✗ | new_return(44); | |
| 7735 | } | ||
| 7736 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(DMaps[i].tmusic_xfade_out, f)) |
| 7737 | { | ||
| 7738 | ✗ | new_return(45); | |
| 7739 | } | ||
| 7740 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(DMaps[i].overlay_subscreen, f)) |
| 7741 | ✗ | new_return(46); | |
| 7742 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(DMaps[i].intro_string_id, f)) |
| 7743 | ✗ | new_return(47); | |
| 7744 | 9216 | } | |
| 7745 | |||
| 7746 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 7747 | { | ||
| 7748 | 9 | section_size=writesize; | |
| 7749 | 9 | } | |
| 7750 | 18 | } | |
| 7751 | |||
| 7752 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 7753 | { | ||
| 7754 | char ebuf[80]; | ||
| 7755 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 7756 | ✗ | jwin_alert("Error: writedmaps()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 7757 | ✗ | } | |
| 7758 | |||
| 7759 | 9 | new_return(0); | |
| 7760 | } | ||
| 7761 | |||
| 7762 | 9 | int32_t writemisccolors(PACKFILE *f, zquestheader *Header) | |
| 7763 | { | ||
| 7764 | //these are here to bypass compiler warnings about unused arguments | ||
| 7765 | 9 | Header=Header; | |
| 7766 | |||
| 7767 | 9 | dword section_id=ID_COLORS; | |
| 7768 | 9 | dword section_version=V_COLORS; | |
| 7769 | 9 | dword section_size = 0; | |
| 7770 | |||
| 7771 | //section id | ||
| 7772 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 7773 | { | ||
| 7774 | ✗ | new_return(1); | |
| 7775 | } | ||
| 7776 | |||
| 7777 | |||
| 7778 | //section version info | ||
| 7779 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 7780 | { | ||
| 7781 | ✗ | new_return(2); | |
| 7782 | } | ||
| 7783 | |||
| 7784 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 7785 | { | ||
| 7786 | ✗ | new_return(3); | |
| 7787 | } | ||
| 7788 | |||
| 7789 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 7790 | { | ||
| 7791 | 18 | fake_pack_writing=(writecycle==0); | |
| 7792 | |||
| 7793 | //section size | ||
| 7794 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 7795 | { | ||
| 7796 | ✗ | new_return(4); | |
| 7797 | } | ||
| 7798 | |||
| 7799 | 18 | writesize=0; | |
| 7800 | |||
| 7801 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.text,f)) |
| 7802 | { | ||
| 7803 | ✗ | new_return(5); | |
| 7804 | } | ||
| 7805 | |||
| 7806 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.caption,f)) |
| 7807 | { | ||
| 7808 | ✗ | new_return(6); | |
| 7809 | } | ||
| 7810 | |||
| 7811 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.overw_bg,f)) |
| 7812 | { | ||
| 7813 | ✗ | new_return(7); | |
| 7814 | } | ||
| 7815 | |||
| 7816 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.dngn_bg,f)) |
| 7817 | { | ||
| 7818 | ✗ | new_return(8); | |
| 7819 | } | ||
| 7820 | |||
| 7821 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.dngn_fg,f)) |
| 7822 | { | ||
| 7823 | ✗ | new_return(9); | |
| 7824 | } | ||
| 7825 | |||
| 7826 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.cave_fg,f)) |
| 7827 | { | ||
| 7828 | ✗ | new_return(10); | |
| 7829 | } | ||
| 7830 | |||
| 7831 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.bs_dk,f)) |
| 7832 | { | ||
| 7833 | ✗ | new_return(11); | |
| 7834 | } | ||
| 7835 | |||
| 7836 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.bs_goal,f)) |
| 7837 | { | ||
| 7838 | ✗ | new_return(12); | |
| 7839 | } | ||
| 7840 | |||
| 7841 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.compass_lt,f)) |
| 7842 | { | ||
| 7843 | ✗ | new_return(13); | |
| 7844 | } | ||
| 7845 | |||
| 7846 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.compass_dk,f)) |
| 7847 | { | ||
| 7848 | ✗ | new_return(14); | |
| 7849 | } | ||
| 7850 | |||
| 7851 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.subscr_bg,f)) |
| 7852 | { | ||
| 7853 | ✗ | new_return(15); | |
| 7854 | } | ||
| 7855 | |||
| 7856 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.triframe_color,f)) |
| 7857 | { | ||
| 7858 | ✗ | new_return(16); | |
| 7859 | } | ||
| 7860 | |||
| 7861 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.hero_dot,f)) |
| 7862 | { | ||
| 7863 | ✗ | new_return(17); | |
| 7864 | } | ||
| 7865 | |||
| 7866 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.bmap_bg,f)) |
| 7867 | { | ||
| 7868 | ✗ | new_return(18); | |
| 7869 | } | ||
| 7870 | |||
| 7871 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.bmap_fg,f)) |
| 7872 | { | ||
| 7873 | ✗ | new_return(19); | |
| 7874 | } | ||
| 7875 | |||
| 7876 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.triforce_cset,f)) |
| 7877 | { | ||
| 7878 | ✗ | new_return(20); | |
| 7879 | } | ||
| 7880 | |||
| 7881 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.triframe_cset,f)) |
| 7882 | { | ||
| 7883 | ✗ | new_return(21); | |
| 7884 | } | ||
| 7885 | |||
| 7886 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.overworld_map_cset,f)) |
| 7887 | { | ||
| 7888 | ✗ | new_return(22); | |
| 7889 | } | ||
| 7890 | |||
| 7891 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.dungeon_map_cset,f)) |
| 7892 | { | ||
| 7893 | ✗ | new_return(23); | |
| 7894 | } | ||
| 7895 | |||
| 7896 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.blueframe_cset,f)) |
| 7897 | { | ||
| 7898 | ✗ | new_return(24); | |
| 7899 | } | ||
| 7900 | |||
| 7901 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.HCpieces_cset,f)) |
| 7902 | { | ||
| 7903 | ✗ | new_return(31); | |
| 7904 | } | ||
| 7905 | |||
| 7906 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.subscr_shadow,f)) |
| 7907 | { | ||
| 7908 | ✗ | new_return(32); | |
| 7909 | } | ||
| 7910 | |||
| 7911 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(QMisc.colors.msgtext,f)) |
| 7912 | { | ||
| 7913 | ✗ | new_return(33); | |
| 7914 | } | ||
| 7915 | |||
| 7916 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(QMisc.colors.triforce_tile,f)) |
| 7917 | { | ||
| 7918 | ✗ | new_return(34); | |
| 7919 | } | ||
| 7920 | |||
| 7921 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(QMisc.colors.triframe_tile,f)) |
| 7922 | { | ||
| 7923 | ✗ | new_return(35); | |
| 7924 | } | ||
| 7925 | |||
| 7926 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(QMisc.colors.overworld_map_tile,f)) |
| 7927 | { | ||
| 7928 | ✗ | new_return(36); | |
| 7929 | } | ||
| 7930 | |||
| 7931 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(QMisc.colors.dungeon_map_tile,f)) |
| 7932 | { | ||
| 7933 | ✗ | new_return(37); | |
| 7934 | } | ||
| 7935 | |||
| 7936 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(QMisc.colors.blueframe_tile,f)) |
| 7937 | { | ||
| 7938 | ✗ | new_return(38); | |
| 7939 | } | ||
| 7940 | |||
| 7941 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(QMisc.colors.HCpieces_tile,f)) |
| 7942 | { | ||
| 7943 | ✗ | new_return(39); | |
| 7944 | } | ||
| 7945 | |||
| 7946 | |||
| 7947 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 7948 | { | ||
| 7949 | 9 | section_size=writesize; | |
| 7950 | 9 | } | |
| 7951 | 18 | } | |
| 7952 | |||
| 7953 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 7954 | { | ||
| 7955 | char ebuf[80]; | ||
| 7956 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 7957 | ✗ | jwin_alert("Error: writemisccolors()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 7958 | ✗ | } | |
| 7959 | |||
| 7960 | 9 | new_return(0); | |
| 7961 | } | ||
| 7962 | |||
| 7963 | 9 | int32_t writegameicons(PACKFILE *f, zquestheader *Header) | |
| 7964 | { | ||
| 7965 | //these are here to bypass compiler warnings about unused arguments | ||
| 7966 | 9 | Header=Header; | |
| 7967 | |||
| 7968 | 9 | dword section_id=ID_ICONS; | |
| 7969 | 9 | dword section_version=V_ICONS; | |
| 7970 | 9 | dword section_size = 0; | |
| 7971 | |||
| 7972 | //section id | ||
| 7973 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 7974 | { | ||
| 7975 | ✗ | new_return(1); | |
| 7976 | } | ||
| 7977 | |||
| 7978 | //section version info | ||
| 7979 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 7980 | { | ||
| 7981 | ✗ | new_return(2); | |
| 7982 | } | ||
| 7983 | |||
| 7984 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 7985 | { | ||
| 7986 | ✗ | new_return(3); | |
| 7987 | } | ||
| 7988 | |||
| 7989 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 7990 | { | ||
| 7991 | 18 | fake_pack_writing=(writecycle==0); | |
| 7992 | |||
| 7993 | //section size | ||
| 7994 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 7995 | { | ||
| 7996 | ✗ | new_return(4); | |
| 7997 | } | ||
| 7998 | |||
| 7999 | 18 | writesize=0; | |
| 8000 | |||
| 8001 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 8002 | { | ||
| 8003 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(QMisc.icons[i],f)) |
| 8004 | { | ||
| 8005 | ✗ | new_return(5); | |
| 8006 | } | ||
| 8007 | 72 | } | |
| 8008 | |||
| 8009 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 8010 | { | ||
| 8011 | 9 | section_size=writesize; | |
| 8012 | 9 | } | |
| 8013 | 18 | } | |
| 8014 | |||
| 8015 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 8016 | { | ||
| 8017 | char ebuf[80]; | ||
| 8018 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 8019 | ✗ | jwin_alert("Error: writegameicons()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 8020 | ✗ | } | |
| 8021 | |||
| 8022 | 9 | new_return(0); | |
| 8023 | } | ||
| 8024 | |||
| 8025 | 9 | int32_t writemisc(PACKFILE *f, zquestheader *Header) | |
| 8026 | { | ||
| 8027 | //these are here to bypass compiler warnings about unused arguments | ||
| 8028 | 9 | Header=Header; | |
| 8029 | |||
| 8030 | 9 | dword section_id=ID_MISC; | |
| 8031 | 9 | dword section_version=V_MISC; | |
| 8032 | 9 | word shops=count_shops(&QMisc); | |
| 8033 | 9 | word infos=count_infos(&QMisc); | |
| 8034 | 9 | word warprings=count_warprings(&QMisc); | |
| 8035 | 9 | word triforces=8; | |
| 8036 | 9 | dword section_size = 0; | |
| 8037 | |||
| 8038 | //section id | ||
| 8039 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 8040 | { | ||
| 8041 | ✗ | new_return(1); | |
| 8042 | } | ||
| 8043 | |||
| 8044 | |||
| 8045 | //section version info | ||
| 8046 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 8047 | { | ||
| 8048 | ✗ | new_return(2); | |
| 8049 | } | ||
| 8050 | |||
| 8051 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 8052 | { | ||
| 8053 | ✗ | new_return(3); | |
| 8054 | } | ||
| 8055 | |||
| 8056 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 8057 | { | ||
| 8058 | 18 | fake_pack_writing=(writecycle==0); | |
| 8059 | |||
| 8060 | //section size | ||
| 8061 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 8062 | { | ||
| 8063 | ✗ | new_return(4); | |
| 8064 | } | ||
| 8065 | |||
| 8066 | 18 | writesize=0; | |
| 8067 | |||
| 8068 | //shops | ||
| 8069 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(shops,f)) |
| 8070 | { | ||
| 8071 | ✗ | new_return(5); | |
| 8072 | } | ||
| 8073 | |||
| 8074 |
2/2✓ Branch 0 taken 160 times.
✓ Branch 1 taken 18 times.
|
178 | for(int32_t i=0; i<shops; i++) |
| 8075 | { | ||
| 8076 |
1/2✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
|
160 | if(!pfwrite(QMisc.shop[i].name,sizeof(QMisc.shop[i].name)-1,f)) |
| 8077 | { | ||
| 8078 | ✗ | new_return(6); | |
| 8079 | } | ||
| 8080 | |||
| 8081 |
2/2✓ Branch 0 taken 480 times.
✓ Branch 1 taken 160 times.
|
640 | for(int32_t j=0; j<3; j++) |
| 8082 | { | ||
| 8083 |
1/2✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
|
480 | if(!p_putc(QMisc.shop[i].item[j],f)) |
| 8084 | { | ||
| 8085 | ✗ | new_return(7); | |
| 8086 | } | ||
| 8087 | 480 | } | |
| 8088 | |||
| 8089 |
2/2✓ Branch 0 taken 480 times.
✓ Branch 1 taken 160 times.
|
640 | for(int32_t j=0; j<3; j++) |
| 8090 | { | ||
| 8091 |
1/2✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
|
480 | if(!p_iputw(QMisc.shop[i].price[j],f)) |
| 8092 | { | ||
| 8093 | ✗ | new_return(8); | |
| 8094 | } | ||
| 8095 | 480 | } | |
| 8096 | |||
| 8097 |
2/2✓ Branch 0 taken 480 times.
✓ Branch 1 taken 160 times.
|
640 | for(int32_t j=0; j<3; j++) |
| 8098 | { | ||
| 8099 |
1/2✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
|
480 | if(!p_putc(QMisc.shop[i].hasitem[j],f)) |
| 8100 | { | ||
| 8101 | ✗ | new_return(9); | |
| 8102 | } | ||
| 8103 | 480 | } | |
| 8104 | 160 | } | |
| 8105 | |||
| 8106 | //infos | ||
| 8107 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(infos,f)) |
| 8108 | { | ||
| 8109 | ✗ | new_return(10); | |
| 8110 | } | ||
| 8111 | |||
| 8112 |
2/2✓ Branch 0 taken 160 times.
✓ Branch 1 taken 18 times.
|
178 | for(int32_t i=0; i<infos; i++) |
| 8113 | { | ||
| 8114 |
1/2✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
|
160 | if(!pfwrite(QMisc.info[i].name,sizeof(QMisc.info[i].name)-1,f)) |
| 8115 | { | ||
| 8116 | ✗ | new_return(11); | |
| 8117 | } | ||
| 8118 | |||
| 8119 |
2/2✓ Branch 0 taken 480 times.
✓ Branch 1 taken 160 times.
|
640 | for(int32_t j=0; j<3; j++) |
| 8120 | { | ||
| 8121 |
1/2✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
|
480 | if(!p_iputw(QMisc.info[i].str[j],f)) |
| 8122 | { | ||
| 8123 | ✗ | new_return(12); | |
| 8124 | } | ||
| 8125 | 480 | } | |
| 8126 | |||
| 8127 |
2/2✓ Branch 0 taken 480 times.
✓ Branch 1 taken 160 times.
|
640 | for(int32_t j=0; j<3; j++) |
| 8128 | { | ||
| 8129 |
1/2✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
|
480 | if(!p_iputw(QMisc.info[i].price[j],f)) |
| 8130 | { | ||
| 8131 | ✗ | new_return(13); | |
| 8132 | } | ||
| 8133 | 480 | } | |
| 8134 | 160 | } | |
| 8135 | |||
| 8136 | //warp rings | ||
| 8137 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(warprings,f)) |
| 8138 | { | ||
| 8139 | ✗ | new_return(14); | |
| 8140 | } | ||
| 8141 | |||
| 8142 |
2/2✓ Branch 0 taken 208 times.
✓ Branch 1 taken 18 times.
|
226 | for(int32_t i=0; i<warprings; i++) |
| 8143 | { | ||
| 8144 |
2/2✓ Branch 0 taken 1872 times.
✓ Branch 1 taken 208 times.
|
2080 | for(int32_t j=0; j<9; j++) |
| 8145 | { | ||
| 8146 |
1/2✓ Branch 0 taken 1872 times.
✗ Branch 1 not taken.
|
1872 | if(!p_iputw(QMisc.warp[i].dmap[j],f)) |
| 8147 | { | ||
| 8148 | ✗ | new_return(15); | |
| 8149 | } | ||
| 8150 | 1872 | } | |
| 8151 | |||
| 8152 |
2/2✓ Branch 0 taken 1872 times.
✓ Branch 1 taken 208 times.
|
2080 | for(int32_t j=0; j<9; j++) |
| 8153 | { | ||
| 8154 |
1/2✓ Branch 0 taken 1872 times.
✗ Branch 1 not taken.
|
1872 | if(!p_putc(QMisc.warp[i].scr[j],f)) |
| 8155 | { | ||
| 8156 | ✗ | new_return(16); | |
| 8157 | } | ||
| 8158 | 1872 | } | |
| 8159 | |||
| 8160 |
1/2✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
|
208 | if(!p_putc(QMisc.warp[i].size,f)) |
| 8161 | { | ||
| 8162 | ✗ | new_return(17); | |
| 8163 | } | ||
| 8164 | 208 | } | |
| 8165 | |||
| 8166 | //triforce pieces | ||
| 8167 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 18 times.
|
162 | for(int32_t i=0; i<triforces; i++) |
| 8168 | { | ||
| 8169 |
1/2✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
|
144 | if(!p_putc(QMisc.triforce[i],f)) |
| 8170 | { | ||
| 8171 | ✗ | new_return(18); | |
| 8172 | } | ||
| 8173 | 144 | } | |
| 8174 | |||
| 8175 | //end string | ||
| 8176 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(QMisc.endstring,f)) |
| 8177 | { | ||
| 8178 | ✗ | new_return(19); | |
| 8179 | } | ||
| 8180 | |||
| 8181 | //V_MISC >= 8 | ||
| 8182 |
2/2✓ Branch 0 taken 160 times.
✓ Branch 1 taken 18 times.
|
178 | for(int32_t i=0; i<shops; i++) |
| 8183 | { | ||
| 8184 |
2/2✓ Branch 0 taken 480 times.
✓ Branch 1 taken 160 times.
|
640 | for(int32_t j=0; j<3; j++) |
| 8185 | { | ||
| 8186 |
1/2✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
|
480 | if(!p_iputw(QMisc.shop[i].str[j],f)) |
| 8187 | { | ||
| 8188 | ✗ | new_return(20); | |
| 8189 | } | ||
| 8190 | 480 | } | |
| 8191 | 160 | } | |
| 8192 | //V_MISC >= 9 | ||
| 8193 |
2/2✓ Branch 0 taken 576 times.
✓ Branch 1 taken 18 times.
|
594 | for ( int32_t q = 0; q < 32; q++ ) |
| 8194 | { | ||
| 8195 |
1/2✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
|
576 | if(!p_iputl(QMisc.questmisc[q],f)) |
| 8196 | ✗ | new_return(21); | |
| 8197 | 576 | } | |
| 8198 |
2/2✓ Branch 0 taken 576 times.
✓ Branch 1 taken 18 times.
|
594 | for ( int32_t q = 0; q < 32; q++ ) |
| 8199 | { | ||
| 8200 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 576 times.
|
74304 | for ( int32_t j = 0; j < 128; j++ ) |
| 8201 |
1/2✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
|
73728 | if(!p_putc(0,f)) |
| 8202 | ✗ | new_return(22); | |
| 8203 | 576 | } | |
| 8204 | //V_MISC >= 11 | ||
| 8205 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(QMisc.zscript_last_compiled_version,f)) |
| 8206 | ✗ | new_return(23); | |
| 8207 | |||
| 8208 | //V_MISC >= 12 | ||
| 8209 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 18 times.
|
4626 | for(int32_t q = 0; q < sprMAX; ++q) |
| 8210 | { | ||
| 8211 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(QMisc.sprites[q],f)) |
| 8212 | ✗ | new_return(24); | |
| 8213 | 4608 | } | |
| 8214 | |||
| 8215 | //V_MISC >= 13 | ||
| 8216 |
2/2✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 18 times.
|
1170 | for(size_t q = 0; q < 64; ++q) |
| 8217 | { | ||
| 8218 | 1152 | bottletype* bt = &(QMisc.bottle_types[q]); | |
| 8219 |
1/2✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
|
1152 | if (!pfwrite(bt->name, 32, f)) |
| 8220 | ✗ | new_return(25); | |
| 8221 |
2/2✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 1152 times.
|
4608 | for(size_t j = 0; j < 3; ++j) |
| 8222 | { | ||
| 8223 |
1/2✓ Branch 0 taken 3456 times.
✗ Branch 1 not taken.
|
3456 | if (!p_putc(bt->counter[j], f)) |
| 8224 | ✗ | new_return(25); | |
| 8225 |
1/2✓ Branch 0 taken 3456 times.
✗ Branch 1 not taken.
|
3456 | if (!p_iputw(bt->amount[j], f)) |
| 8226 | ✗ | new_return(25); | |
| 8227 | 3456 | } | |
| 8228 |
1/2✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
|
1152 | if (!p_putc(bt->flags, f)) |
| 8229 | ✗ | new_return(25); | |
| 8230 |
1/2✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
|
1152 | if (!p_putc(bt->next_type, f)) |
| 8231 | ✗ | new_return(25); | |
| 8232 | 1152 | } | |
| 8233 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 18 times.
|
4626 | for(size_t q = 0; q < 256; ++q) |
| 8234 | { | ||
| 8235 | 4608 | bottleshoptype* bst = &(QMisc.bottle_shop_types[q]); | |
| 8236 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if (!pfwrite(bst->name, 32, f)) |
| 8237 | ✗ | new_return(26); | |
| 8238 |
2/2✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 4608 times.
|
18432 | for(size_t j = 0; j < 3; ++j) |
| 8239 | { | ||
| 8240 |
1/2✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
|
13824 | if (!p_putc(bst->fill[j], f)) |
| 8241 | ✗ | new_return(26); | |
| 8242 |
1/2✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
|
13824 | if (!p_iputw(bst->comb[j], f)) |
| 8243 | ✗ | new_return(26); | |
| 8244 |
1/2✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
|
13824 | if (!p_putc(bst->cset[j], f)) |
| 8245 | ✗ | new_return(26); | |
| 8246 |
1/2✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
|
13824 | if (!p_iputw(bst->price[j], f)) |
| 8247 | ✗ | new_return(26); | |
| 8248 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 13824 times.
|
13824 | if (!p_iputw(bst->str[j], f)) |
| 8249 | ✗ | new_return(26); | |
| 8250 | 13824 | } | |
| 8251 | 4608 | } | |
| 8252 | |||
| 8253 | //V_MISC >= 14 | ||
| 8254 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 18 times.
|
4626 | for(int32_t q = 0; q < sfxMAX; ++q) |
| 8255 | { | ||
| 8256 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(QMisc.miscsfx[q],f)) |
| 8257 | ✗ | new_return(27); | |
| 8258 | 4608 | } | |
| 8259 | |||
| 8260 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 8261 | { | ||
| 8262 | 9 | section_size=writesize; | |
| 8263 | 9 | } | |
| 8264 | 18 | } | |
| 8265 | |||
| 8266 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 8267 | { | ||
| 8268 | char ebuf[80]; | ||
| 8269 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 8270 | ✗ | jwin_alert("Error: writemisc()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 8271 | ✗ | } | |
| 8272 | |||
| 8273 | 9 | new_return(0); | |
| 8274 | } | ||
| 8275 | |||
| 8276 | 9 | int32_t writeitems(PACKFILE *f, zquestheader *Header) | |
| 8277 | { | ||
| 8278 | //these are here to bypass compiler warnings about unused arguments | ||
| 8279 | 9 | Header=Header; | |
| 8280 | |||
| 8281 | 9 | dword section_id=ID_ITEMS; | |
| 8282 | 9 | dword section_version=V_ITEMS; | |
| 8283 | // dword section_size=0; | ||
| 8284 | 9 | dword section_size = 0; | |
| 8285 | |||
| 8286 | //section id | ||
| 8287 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 8288 | { | ||
| 8289 | ✗ | new_return(1); | |
| 8290 | } | ||
| 8291 | |||
| 8292 | //section version info | ||
| 8293 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 8294 | { | ||
| 8295 | ✗ | new_return(2); | |
| 8296 | } | ||
| 8297 | |||
| 8298 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 8299 | { | ||
| 8300 | ✗ | new_return(3); | |
| 8301 | } | ||
| 8302 | |||
| 8303 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 8304 | { | ||
| 8305 | 18 | fake_pack_writing=(writecycle==0); | |
| 8306 | |||
| 8307 | //section size | ||
| 8308 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 8309 | { | ||
| 8310 | ✗ | new_return(4); | |
| 8311 | } | ||
| 8312 | |||
| 8313 | 18 | writesize=0; | |
| 8314 | |||
| 8315 | //finally... section data | ||
| 8316 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(MAXITEMS,f)) |
| 8317 | { | ||
| 8318 | ✗ | new_return(5); | |
| 8319 | } | ||
| 8320 | |||
| 8321 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 18 times.
|
4626 | for(int32_t i=0; i<MAXITEMS; i++) |
| 8322 | { | ||
| 8323 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!pfwrite(item_string[i], 64, f)) |
| 8324 | { | ||
| 8325 | ✗ | new_return(5); | |
| 8326 | } | ||
| 8327 | 4608 | } | |
| 8328 | |||
| 8329 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 18 times.
|
4626 | for(int32_t i=0; i<MAXITEMS; i++) |
| 8330 | { | ||
| 8331 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].tile,f)) |
| 8332 | { | ||
| 8333 | ✗ | new_return(6); | |
| 8334 | } | ||
| 8335 | |||
| 8336 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].misc_flags,f)) |
| 8337 | { | ||
| 8338 | ✗ | new_return(7); | |
| 8339 | } | ||
| 8340 | |||
| 8341 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].csets,f)) |
| 8342 | { | ||
| 8343 | ✗ | new_return(8); | |
| 8344 | } | ||
| 8345 | |||
| 8346 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].frames,f)) |
| 8347 | { | ||
| 8348 | ✗ | new_return(9); | |
| 8349 | } | ||
| 8350 | |||
| 8351 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].speed,f)) |
| 8352 | { | ||
| 8353 | ✗ | new_return(10); | |
| 8354 | } | ||
| 8355 | |||
| 8356 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].delay,f)) |
| 8357 | { | ||
| 8358 | ✗ | new_return(11); | |
| 8359 | } | ||
| 8360 | |||
| 8361 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].ltm,f)) |
| 8362 | { | ||
| 8363 | ✗ | new_return(12); | |
| 8364 | } | ||
| 8365 | |||
| 8366 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].family,f)) |
| 8367 | { | ||
| 8368 | ✗ | new_return(13); | |
| 8369 | } | ||
| 8370 | |||
| 8371 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].fam_type,f)) |
| 8372 | { | ||
| 8373 | ✗ | new_return(14); | |
| 8374 | } | ||
| 8375 | |||
| 8376 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].power,f)) |
| 8377 | { | ||
| 8378 | ✗ | new_return(14); | |
| 8379 | } | ||
| 8380 | |||
| 8381 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].flags,f)) |
| 8382 | { | ||
| 8383 | ✗ | new_return(15); | |
| 8384 | } | ||
| 8385 | |||
| 8386 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputw(itemsbuf[i].script,f)) |
| 8387 | { | ||
| 8388 | ✗ | new_return(16); | |
| 8389 | } | ||
| 8390 | |||
| 8391 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].count,f)) |
| 8392 | { | ||
| 8393 | ✗ | new_return(17); | |
| 8394 | } | ||
| 8395 | |||
| 8396 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputw(itemsbuf[i].amount,f)) |
| 8397 | { | ||
| 8398 | ✗ | new_return(18); | |
| 8399 | } | ||
| 8400 | |||
| 8401 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputw(itemsbuf[i].collect_script,f)) |
| 8402 | { | ||
| 8403 | ✗ | new_return(19); | |
| 8404 | } | ||
| 8405 | |||
| 8406 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputw(itemsbuf[i].setmax,f)) |
| 8407 | { | ||
| 8408 | ✗ | new_return(21); | |
| 8409 | } | ||
| 8410 | |||
| 8411 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputw(itemsbuf[i].max,f)) |
| 8412 | { | ||
| 8413 | ✗ | new_return(22); | |
| 8414 | } | ||
| 8415 | |||
| 8416 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].playsound,f)) |
| 8417 | { | ||
| 8418 | ✗ | new_return(23); | |
| 8419 | } | ||
| 8420 | |||
| 8421 |
2/2✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 4608 times.
|
41472 | for(int32_t j=0; j<8; j++) |
| 8422 | { | ||
| 8423 |
1/2✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
|
36864 | if(!p_iputl(itemsbuf[i].initiald[j],f)) |
| 8424 | { | ||
| 8425 | ✗ | new_return(24); | |
| 8426 | } | ||
| 8427 | 36864 | } | |
| 8428 | |||
| 8429 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 4608 times.
|
13824 | for(int32_t j=0; j<2; j++) |
| 8430 | { | ||
| 8431 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(0,f)) |
| 8432 | { | ||
| 8433 | ✗ | new_return(25); | |
| 8434 | } | ||
| 8435 | 9216 | } | |
| 8436 | |||
| 8437 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].wpn,f)) |
| 8438 | { | ||
| 8439 | ✗ | new_return(26); | |
| 8440 | } | ||
| 8441 | |||
| 8442 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].wpn2,f)) |
| 8443 | { | ||
| 8444 | ✗ | new_return(27); | |
| 8445 | } | ||
| 8446 | |||
| 8447 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].wpn3,f)) |
| 8448 | { | ||
| 8449 | ✗ | new_return(28); | |
| 8450 | } | ||
| 8451 | |||
| 8452 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].wpn4,f)) |
| 8453 | { | ||
| 8454 | ✗ | new_return(29); | |
| 8455 | } | ||
| 8456 | |||
| 8457 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].wpn5,f)) |
| 8458 | { | ||
| 8459 | ✗ | new_return(30); | |
| 8460 | } | ||
| 8461 | |||
| 8462 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].wpn6,f)) |
| 8463 | { | ||
| 8464 | ✗ | new_return(31); | |
| 8465 | } | ||
| 8466 | |||
| 8467 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].wpn7,f)) |
| 8468 | { | ||
| 8469 | ✗ | new_return(32); | |
| 8470 | } | ||
| 8471 | |||
| 8472 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].wpn8,f)) |
| 8473 | { | ||
| 8474 | ✗ | new_return(33); | |
| 8475 | } | ||
| 8476 | |||
| 8477 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].wpn9,f)) |
| 8478 | { | ||
| 8479 | ✗ | new_return(34); | |
| 8480 | } | ||
| 8481 | |||
| 8482 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].wpn10,f)) |
| 8483 | { | ||
| 8484 | ✗ | new_return(35); | |
| 8485 | } | ||
| 8486 | |||
| 8487 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].pickup_hearts,f)) |
| 8488 | { | ||
| 8489 | ✗ | new_return(36); | |
| 8490 | } | ||
| 8491 | |||
| 8492 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].misc1,f)) |
| 8493 | { | ||
| 8494 | ✗ | new_return(37); | |
| 8495 | } | ||
| 8496 | |||
| 8497 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].misc2,f)) |
| 8498 | { | ||
| 8499 | ✗ | new_return(38); | |
| 8500 | } | ||
| 8501 | |||
| 8502 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 4608 times.
|
13824 | for(auto q = 0; q < 2; ++q) |
| 8503 | { | ||
| 8504 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(itemsbuf[i].cost_amount[q],f)) |
| 8505 | { | ||
| 8506 | ✗ | new_return(39); | |
| 8507 | } | ||
| 8508 | 9216 | } | |
| 8509 | |||
| 8510 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].misc3,f)) |
| 8511 | { | ||
| 8512 | ✗ | new_return(40); | |
| 8513 | } | ||
| 8514 | |||
| 8515 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].misc4,f)) |
| 8516 | { | ||
| 8517 | ✗ | new_return(41); | |
| 8518 | } | ||
| 8519 | |||
| 8520 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].misc5,f)) |
| 8521 | { | ||
| 8522 | ✗ | new_return(42); | |
| 8523 | } | ||
| 8524 | |||
| 8525 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].misc6,f)) |
| 8526 | { | ||
| 8527 | ✗ | new_return(43); | |
| 8528 | } | ||
| 8529 | |||
| 8530 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].misc7,f)) |
| 8531 | { | ||
| 8532 | ✗ | new_return(44); | |
| 8533 | } | ||
| 8534 | |||
| 8535 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].misc8,f)) |
| 8536 | { | ||
| 8537 | ✗ | new_return(45); | |
| 8538 | } | ||
| 8539 | |||
| 8540 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].misc9,f)) |
| 8541 | { | ||
| 8542 | ✗ | new_return(46); | |
| 8543 | } | ||
| 8544 | |||
| 8545 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].misc10,f)) |
| 8546 | { | ||
| 8547 | ✗ | new_return(47); | |
| 8548 | } | ||
| 8549 | |||
| 8550 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].usesound,f)) |
| 8551 | { | ||
| 8552 | ✗ | new_return(48); | |
| 8553 | } | ||
| 8554 | |||
| 8555 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].usesound2,f)) |
| 8556 | { | ||
| 8557 | ✗ | new_return(48); | |
| 8558 | } | ||
| 8559 | |||
| 8560 | //New itemdata vars -Z | ||
| 8561 | //! version 27 | ||
| 8562 | |||
| 8563 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].useweapon,f)) |
| 8564 | { | ||
| 8565 | ✗ | new_return(49); | |
| 8566 | } | ||
| 8567 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].usedefence,f)) |
| 8568 | { | ||
| 8569 | ✗ | new_return(50); | |
| 8570 | } | ||
| 8571 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weaprange,f)) |
| 8572 | { | ||
| 8573 | ✗ | new_return(51); | |
| 8574 | } | ||
| 8575 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weapduration,f)) |
| 8576 | { | ||
| 8577 | ✗ | new_return(52); | |
| 8578 | } | ||
| 8579 |
2/2✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 4608 times.
|
50688 | for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ ) { |
| 8580 |
1/2✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
|
46080 | if(!p_iputl(itemsbuf[i].weap_pattern[q],f)) |
| 8581 | { | ||
| 8582 | ✗ | new_return(53); | |
| 8583 | } | ||
| 8584 | 46080 | } | |
| 8585 | //version 28 | ||
| 8586 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].duplicates,f)) |
| 8587 | { | ||
| 8588 | ✗ | new_return(54); | |
| 8589 | } | ||
| 8590 |
2/2✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 4608 times.
|
41472 | for ( int32_t q = 0; q < INITIAL_D; q++ ) |
| 8591 | { | ||
| 8592 |
1/2✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
|
36864 | if(!p_iputl(itemsbuf[i].weap_initiald[q],f)) |
| 8593 | { | ||
| 8594 | ✗ | new_return(55); | |
| 8595 | } | ||
| 8596 | 36864 | } | |
| 8597 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 4608 times.
|
13824 | for ( int32_t q = 0; q < 2; q++ ) |
| 8598 | { | ||
| 8599 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(0,f)) |
| 8600 | { | ||
| 8601 | ✗ | new_return(56); | |
| 8602 | } | ||
| 8603 | 9216 | } | |
| 8604 | |||
| 8605 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].drawlayer,f)) |
| 8606 | { | ||
| 8607 | ✗ | new_return(57); | |
| 8608 | } | ||
| 8609 | |||
| 8610 | |||
| 8611 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].hxofs,f)) |
| 8612 | { | ||
| 8613 | ✗ | new_return(58); | |
| 8614 | } | ||
| 8615 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].hyofs,f)) |
| 8616 | { | ||
| 8617 | ✗ | new_return(59); | |
| 8618 | } | ||
| 8619 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].hxsz,f)) |
| 8620 | { | ||
| 8621 | ✗ | new_return(60); | |
| 8622 | } | ||
| 8623 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].hysz,f)) |
| 8624 | { | ||
| 8625 | ✗ | new_return(61); | |
| 8626 | } | ||
| 8627 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].hzsz,f)) |
| 8628 | { | ||
| 8629 | ✗ | new_return(62); | |
| 8630 | } | ||
| 8631 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].xofs,f)) |
| 8632 | { | ||
| 8633 | ✗ | new_return(63); | |
| 8634 | } | ||
| 8635 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].yofs,f)) |
| 8636 | { | ||
| 8637 | ✗ | new_return(64); | |
| 8638 | } | ||
| 8639 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weap_hxofs,f)) |
| 8640 | { | ||
| 8641 | ✗ | new_return(65); | |
| 8642 | } | ||
| 8643 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weap_hyofs,f)) |
| 8644 | { | ||
| 8645 | ✗ | new_return(66); | |
| 8646 | } | ||
| 8647 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weap_hxsz,f)) |
| 8648 | { | ||
| 8649 | ✗ | new_return(67); | |
| 8650 | } | ||
| 8651 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weap_hysz,f)) |
| 8652 | { | ||
| 8653 | ✗ | new_return(68); | |
| 8654 | } | ||
| 8655 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weap_hzsz,f)) |
| 8656 | { | ||
| 8657 | ✗ | new_return(69); | |
| 8658 | } | ||
| 8659 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weap_xofs,f)) |
| 8660 | { | ||
| 8661 | ✗ | new_return(70); | |
| 8662 | } | ||
| 8663 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weap_yofs,f)) |
| 8664 | { | ||
| 8665 | ✗ | new_return(71); | |
| 8666 | } | ||
| 8667 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputw(itemsbuf[i].weaponscript,f)) |
| 8668 | { | ||
| 8669 | ✗ | new_return(72); | |
| 8670 | } | ||
| 8671 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].wpnsprite,f)) |
| 8672 | { | ||
| 8673 | ✗ | new_return(73); | |
| 8674 | } | ||
| 8675 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 4608 times.
|
13824 | for(auto q = 0; q < 2; ++q) |
| 8676 | { | ||
| 8677 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(itemsbuf[i].magiccosttimer[q],f)) |
| 8678 | { | ||
| 8679 | ✗ | new_return(74); | |
| 8680 | } | ||
| 8681 | 9216 | } | |
| 8682 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].overrideFLAGS,f)) |
| 8683 | { | ||
| 8684 | ✗ | new_return(75); | |
| 8685 | } | ||
| 8686 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].tilew,f)) |
| 8687 | { | ||
| 8688 | ✗ | new_return(76); | |
| 8689 | } | ||
| 8690 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].tileh,f)) |
| 8691 | { | ||
| 8692 | ✗ | new_return(77); | |
| 8693 | } | ||
| 8694 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weapoverrideFLAGS,f)) |
| 8695 | { | ||
| 8696 | ✗ | new_return(78); | |
| 8697 | } | ||
| 8698 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weap_tilew,f)) |
| 8699 | { | ||
| 8700 | ✗ | new_return(79); | |
| 8701 | } | ||
| 8702 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].weap_tileh,f)) |
| 8703 | { | ||
| 8704 | ✗ | new_return(80); | |
| 8705 | } | ||
| 8706 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(itemsbuf[i].pickup,f)) |
| 8707 | { | ||
| 8708 | ✗ | new_return(81); | |
| 8709 | } | ||
| 8710 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputw(itemsbuf[i].pstring,f)) |
| 8711 | { | ||
| 8712 | ✗ | new_return(82); | |
| 8713 | } | ||
| 8714 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputw(itemsbuf[i].pickup_string_flags,f)) |
| 8715 | { | ||
| 8716 | ✗ | new_return(83); | |
| 8717 | } | ||
| 8718 | |||
| 8719 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 4608 times.
|
13824 | for(auto q = 0; q < 2; ++q) |
| 8720 | { | ||
| 8721 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(itemsbuf[i].cost_counter[q],f)) |
| 8722 | { | ||
| 8723 | ✗ | new_return(84); | |
| 8724 | } | ||
| 8725 | 9216 | } | |
| 8726 | |||
| 8727 | //InitD[] labels | ||
| 8728 |
2/2✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 4608 times.
|
41472 | for ( int32_t q = 0; q < 8; q++ ) |
| 8729 | { | ||
| 8730 |
2/2✓ Branch 0 taken 2396160 times.
✓ Branch 1 taken 36864 times.
|
2433024 | for ( int32_t w = 0; w < 65; w++ ) |
| 8731 | { | ||
| 8732 |
1/2✓ Branch 0 taken 2396160 times.
✗ Branch 1 not taken.
|
2396160 | if(!p_putc(itemsbuf[i].initD_label[q][w],f)) |
| 8733 | { | ||
| 8734 | ✗ | new_return(85); | |
| 8735 | } | ||
| 8736 | 2396160 | } | |
| 8737 |
2/2✓ Branch 0 taken 2396160 times.
✓ Branch 1 taken 36864 times.
|
2433024 | for ( int32_t w = 0; w < 65; w++ ) |
| 8738 | { | ||
| 8739 |
1/2✓ Branch 0 taken 2396160 times.
✗ Branch 1 not taken.
|
2396160 | if(!p_putc(itemsbuf[i].weapon_initD_label[q][w],f)) |
| 8740 | { | ||
| 8741 | ✗ | new_return(86); | |
| 8742 | } | ||
| 8743 | 2396160 | } | |
| 8744 |
2/2✓ Branch 0 taken 2396160 times.
✓ Branch 1 taken 36864 times.
|
2433024 | for ( int32_t w = 0; w < 65; w++ ) |
| 8745 | { | ||
| 8746 |
1/2✓ Branch 0 taken 2396160 times.
✗ Branch 1 not taken.
|
2396160 | if(!p_putc(itemsbuf[i].sprite_initD_label[q][w],f)) |
| 8747 | { | ||
| 8748 | ✗ | new_return(87); | |
| 8749 | } | ||
| 8750 | 2396160 | } | |
| 8751 |
1/2✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
|
36864 | if(!p_iputl(itemsbuf[i].sprite_initiald[q],f)) |
| 8752 | { | ||
| 8753 | ✗ | new_return(88); | |
| 8754 | } | ||
| 8755 | 36864 | } | |
| 8756 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 4608 times.
|
13824 | for ( int32_t q = 0; q < 2; q++ ) |
| 8757 | { | ||
| 8758 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(0,f)) |
| 8759 | { | ||
| 8760 | ✗ | new_return(89); | |
| 8761 | } | ||
| 8762 | |||
| 8763 | 9216 | } | |
| 8764 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputw(itemsbuf[i].sprite_script,f)) |
| 8765 | { | ||
| 8766 | ✗ | new_return(90); | |
| 8767 | } | ||
| 8768 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(itemsbuf[i].pickupflag,f)) |
| 8769 | { | ||
| 8770 | ✗ | new_return(91); | |
| 8771 | } | ||
| 8772 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | std::string dispname(itemsbuf[i].display_name); |
| 8773 |
2/4✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4608 times.
✗ Branch 3 not taken.
|
4608 | if(!p_putcstr(dispname,f)) |
| 8774 | ✗ | new_return(92); | |
| 8775 |
2/2✓ Branch 0 taken 23040 times.
✓ Branch 1 taken 4608 times.
|
27648 | for(int q = 0; q < WPNSPR_MAX; ++q) |
| 8776 | { | ||
| 8777 |
2/4✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23040 times.
✗ Branch 3 not taken.
|
23040 | if(!p_putc(itemsbuf[i].burnsprs[q], f)) |
| 8778 | ✗ | new_return(93); | |
| 8779 |
2/4✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23040 times.
✗ Branch 3 not taken.
|
23040 | if(!p_putc(itemsbuf[i].light_rads[q], f)) |
| 8780 | ✗ | new_return(94); | |
| 8781 | 23040 | } | |
| 8782 | 4608 | } | |
| 8783 | |||
| 8784 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 8785 | { | ||
| 8786 | 9 | section_size=writesize; | |
| 8787 | 9 | } | |
| 8788 | 18 | } | |
| 8789 | |||
| 8790 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 8791 | { | ||
| 8792 | char ebuf[80]; | ||
| 8793 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 8794 | ✗ | jwin_alert("Error: writeitems()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 8795 | ✗ | } | |
| 8796 | |||
| 8797 | 9 | new_return(0); | |
| 8798 | ✗ | } | |
| 8799 | |||
| 8800 | 9 | int32_t writeweapons(PACKFILE *f, zquestheader *Header) | |
| 8801 | { | ||
| 8802 | //these are here to bypass compiler warnings about unused arguments | ||
| 8803 | 9 | Header=Header; | |
| 8804 | |||
| 8805 | 9 | dword section_id=ID_WEAPONS; | |
| 8806 | 9 | dword section_version=V_WEAPONS; | |
| 8807 | 9 | dword section_size = 0; | |
| 8808 | |||
| 8809 | //section id | ||
| 8810 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 8811 | { | ||
| 8812 | ✗ | new_return(1); | |
| 8813 | } | ||
| 8814 | |||
| 8815 | //section version info | ||
| 8816 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 8817 | { | ||
| 8818 | ✗ | new_return(2); | |
| 8819 | } | ||
| 8820 | |||
| 8821 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 8822 | { | ||
| 8823 | ✗ | new_return(3); | |
| 8824 | } | ||
| 8825 | |||
| 8826 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 8827 | { | ||
| 8828 | 18 | fake_pack_writing=(writecycle==0); | |
| 8829 | |||
| 8830 | //section size | ||
| 8831 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 8832 | { | ||
| 8833 | ✗ | new_return(4); | |
| 8834 | } | ||
| 8835 | |||
| 8836 | 18 | writesize=0; | |
| 8837 | |||
| 8838 | //finally... section data | ||
| 8839 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(MAXWPNS,f)) |
| 8840 | { | ||
| 8841 | ✗ | new_return(5); | |
| 8842 | } | ||
| 8843 | |||
| 8844 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 18 times.
|
4626 | for(int32_t i=0; i<MAXWPNS; i++) |
| 8845 | { | ||
| 8846 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!pfwrite((char *)weapon_string[i], 64, f)) |
| 8847 | { | ||
| 8848 | ✗ | new_return(5); | |
| 8849 | } | ||
| 8850 | 4608 | } | |
| 8851 | |||
| 8852 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 18 times.
|
4626 | for(int32_t i=0; i<MAXWPNS; i++) |
| 8853 | { | ||
| 8854 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(wpnsbuf[i].misc,f)) |
| 8855 | { | ||
| 8856 | ✗ | new_return(7); | |
| 8857 | } | ||
| 8858 | |||
| 8859 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(wpnsbuf[i].csets,f)) |
| 8860 | { | ||
| 8861 | ✗ | new_return(8); | |
| 8862 | } | ||
| 8863 | |||
| 8864 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(wpnsbuf[i].frames,f)) |
| 8865 | { | ||
| 8866 | ✗ | new_return(9); | |
| 8867 | } | ||
| 8868 | |||
| 8869 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(wpnsbuf[i].speed,f)) |
| 8870 | { | ||
| 8871 | ✗ | new_return(10); | |
| 8872 | } | ||
| 8873 | |||
| 8874 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_putc(wpnsbuf[i].type,f)) |
| 8875 | { | ||
| 8876 | ✗ | new_return(11); | |
| 8877 | } | ||
| 8878 | |||
| 8879 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputw(wpnsbuf[i].script,f)) |
| 8880 | { | ||
| 8881 | ✗ | new_return(12); | |
| 8882 | } | ||
| 8883 | |||
| 8884 |
1/2✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
|
4608 | if(!p_iputl(wpnsbuf[i].tile,f)) |
| 8885 | { | ||
| 8886 | ✗ | new_return(12); | |
| 8887 | } | ||
| 8888 | 4608 | } | |
| 8889 | |||
| 8890 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 8891 | { | ||
| 8892 | 9 | section_size=writesize; | |
| 8893 | 9 | } | |
| 8894 | 18 | } | |
| 8895 | |||
| 8896 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 8897 | { | ||
| 8898 | char ebuf[80]; | ||
| 8899 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 8900 | ✗ | jwin_alert("Error: writeweapons()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 8901 | ✗ | } | |
| 8902 | |||
| 8903 | 9 | new_return(0); | |
| 8904 | } | ||
| 8905 | |||
| 8906 | 12784 | int32_t writemapscreen(PACKFILE *f, int32_t i, int32_t j) | |
| 8907 | { | ||
| 8908 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12784 times.
|
12784 | if((i*MAPSCRS+j)>=int32_t(TheMaps.size())) |
| 8909 | ✗ | return qe_invalid; | |
| 8910 | |||
| 8911 | 12784 | mapscr& screen=TheMaps.at(i*MAPSCRS+j); | |
| 8912 | 12784 | bool is_0x80_screen = j >= 0x80; | |
| 8913 | |||
| 8914 |
1/2✓ Branch 0 taken 12784 times.
✗ Branch 1 not taken.
|
12784 | if(!p_putc(screen.valid,f)) |
| 8915 | ✗ | return qe_invalid; | |
| 8916 |
2/2✓ Branch 0 taken 8376 times.
✓ Branch 1 taken 4408 times.
|
12784 | if(!(screen.valid & mVALID)) |
| 8917 | 4408 | return qe_OK; | |
| 8918 | //Calculate what needs writing | ||
| 8919 | 8376 | uint32_t scr_has_flags = 0; | |
| 8920 |
4/8✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8374 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
8376 | if(screen.guytile || screen.guy || screen.roomflags || screen.str |
| 8921 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2 | || screen.room || screen.catchall) |
| 8922 | 8376 | scr_has_flags |= SCRHAS_ROOMDATA; | |
| 8923 |
7/8✓ Branch 0 taken 7942 times.
✓ Branch 1 taken 434 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 7750 times.
✓ Branch 4 taken 180 times.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 180 times.
|
8376 | if(screen.hasitem || (is_0x80_screen && (screen.itemx||screen.itemy))) |
| 8924 | 446 | scr_has_flags |= SCRHAS_ITEM; | |
| 8925 |
3/4✓ Branch 0 taken 8348 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8348 times.
|
8376 | if((screen.warpreturnc&0x00FF) || screen.tilewarpoverlayflags) |
| 8926 | 28 | scr_has_flags |= SCRHAS_TWARP; | |
| 8927 |
2/2✓ Branch 0 taken 8172 times.
✓ Branch 1 taken 32866 times.
|
41038 | else for(auto q = 0; q < 4; ++q) |
| 8928 | { | ||
| 8929 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 32690 times.
|
65556 | if(screen.tilewarptype[q] |
| 8930 |
2/2✓ Branch 0 taken 32692 times.
✓ Branch 1 taken 174 times.
|
32866 | || screen.tilewarpdmap[q] |
| 8931 |
2/2✓ Branch 0 taken 32690 times.
✓ Branch 1 taken 2 times.
|
32692 | || screen.tilewarpscr[q]) |
| 8932 | { | ||
| 8933 | 176 | scr_has_flags |= SCRHAS_TWARP; | |
| 8934 | 176 | break; | |
| 8935 | } | ||
| 8936 | 32690 | } | |
| 8937 |
3/4✓ Branch 0 taken 8372 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 8340 times.
✗ Branch 3 not taken.
|
8376 | if((screen.warpreturnc&0xFF00) || screen.sidewarpindex |
| 8938 |
2/2✓ Branch 0 taken 8340 times.
✓ Branch 1 taken 32 times.
|
8372 | || screen.sidewarpoverlayflags) |
| 8939 | 36 | scr_has_flags |= SCRHAS_SWARP; | |
| 8940 |
2/2✓ Branch 0 taken 4070 times.
✓ Branch 1 taken 20552 times.
|
24622 | else for(auto q = 0; q < 4; ++q) |
| 8941 | { | ||
| 8942 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 16282 times.
|
36846 | if(screen.sidewarptype[q] != wtSCROLL |
| 8943 |
2/2✓ Branch 0 taken 16420 times.
✓ Branch 1 taken 4132 times.
|
20552 | || screen.sidewarpdmap[q] |
| 8944 |
2/2✓ Branch 0 taken 16294 times.
✓ Branch 1 taken 126 times.
|
16420 | || screen.sidewarpscr[q]) |
| 8945 | { | ||
| 8946 | 4270 | scr_has_flags |= SCRHAS_SWARP; | |
| 8947 | 4270 | break; | |
| 8948 | } | ||
| 8949 | 16282 | } | |
| 8950 |
3/4✓ Branch 0 taken 8332 times.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8332 times.
|
8376 | if(screen.warparrivalx || screen.warparrivaly) |
| 8951 | 44 | scr_has_flags |= SCRHAS_WARPRET; | |
| 8952 |
2/2✓ Branch 0 taken 7550 times.
✓ Branch 1 taken 30982 times.
|
38532 | else for(auto q = 0; q < 4; ++q) |
| 8953 | { | ||
| 8954 |
4/4✓ Branch 0 taken 30202 times.
✓ Branch 1 taken 780 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 30200 times.
|
30982 | if(screen.warpreturnx[q] || screen.warpreturny[q]) |
| 8955 | { | ||
| 8956 | 782 | scr_has_flags |= SCRHAS_WARPRET; | |
| 8957 | 782 | break; | |
| 8958 | } | ||
| 8959 | 30200 | } | |
| 8960 | |||
| 8961 |
2/4✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8376 times.
|
8376 | if(screen.hidelayers || screen.hidescriptlayers) |
| 8962 | ✗ | scr_has_flags |= SCRHAS_LAYERS; | |
| 8963 |
2/2✓ Branch 0 taken 7410 times.
✓ Branch 1 taken 45474 times.
|
52884 | else for(auto q = 0; q < 6; ++q) |
| 8964 | { | ||
| 8965 |
4/4✓ Branch 0 taken 44528 times.
✓ Branch 1 taken 946 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 44508 times.
|
45474 | if(screen.layermap[q] || screen.layerscreen[q] |
| 8966 |
1/2✓ Branch 0 taken 44528 times.
✗ Branch 1 not taken.
|
44528 | || screen.layeropacity[q]!=255) |
| 8967 | { | ||
| 8968 | 966 | scr_has_flags |= SCRHAS_LAYERS; | |
| 8969 | 966 | break; | |
| 8970 | } | ||
| 8971 | 44508 | } | |
| 8972 | |||
| 8973 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 8366 times.
|
8376 | if(screen.exitdir) |
| 8974 | 10 | scr_has_flags |= SCRHAS_MAZE; | |
| 8975 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8366 times.
|
8366 | else if(screen.maze_transition_wipe) |
| 8976 | ✗ | scr_has_flags |= SCRHAS_MAZE; | |
| 8977 |
2/2✓ Branch 0 taken 8366 times.
✓ Branch 1 taken 33464 times.
|
41830 | else for(auto q = 0; q < 4; ++q) |
| 8978 | { | ||
| 8979 |
1/2✓ Branch 0 taken 33464 times.
✗ Branch 1 not taken.
|
33464 | if(screen.path[q]) |
| 8980 | { | ||
| 8981 | ✗ | scr_has_flags |= SCRHAS_MAZE; | |
| 8982 | ✗ | break; | |
| 8983 | } | ||
| 8984 | 33464 | } | |
| 8985 | |||
| 8986 |
4/4✓ Branch 0 taken 8142 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 322 times.
✓ Branch 3 taken 5408 times.
|
14106 | if(screen.door_combo_set || screen.stairx |
| 8987 |
3/4✓ Branch 0 taken 8114 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 8114 times.
✗ Branch 3 not taken.
|
8142 | || screen.stairy || screen.undercombo |
| 8988 |
2/2✓ Branch 0 taken 5730 times.
✓ Branch 1 taken 2384 times.
|
8114 | || screen.undercset) |
| 8989 | 2968 | scr_has_flags |= SCRHAS_D_S_U; | |
| 8990 |
2/2✓ Branch 0 taken 196 times.
✓ Branch 1 taken 5996 times.
|
6192 | else for(auto q = 0; q < 4; ++q) |
| 8991 | { | ||
| 8992 |
2/2✓ Branch 0 taken 784 times.
✓ Branch 1 taken 5212 times.
|
5996 | if(screen.door[q] != dNONE) |
| 8993 | { | ||
| 8994 | 5212 | scr_has_flags |= SCRHAS_D_S_U; | |
| 8995 | 5212 | break; | |
| 8996 | } | ||
| 8997 | 784 | } | |
| 8998 | |||
| 8999 |
2/2✓ Branch 0 taken 8072 times.
✓ Branch 1 taken 304 times.
|
15592 | if(screen.flags || screen.flags2 |
| 9000 |
4/4✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 7694 times.
✓ Branch 3 taken 132 times.
|
8072 | || screen.flags3 || screen.flags4 |
| 9001 |
4/4✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 7658 times.
✓ Branch 3 taken 22 times.
|
7694 | || screen.flags5 || screen.flags6 |
| 9002 |
4/4✓ Branch 0 taken 7444 times.
✓ Branch 1 taken 214 times.
✓ Branch 2 taken 7216 times.
✓ Branch 3 taken 228 times.
|
7658 | || screen.flags7 || screen.flags8 |
| 9003 |
2/4✓ Branch 0 taken 7216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7216 times.
✗ Branch 3 not taken.
|
7216 | || screen.flags9 || screen.flags10 |
| 9004 |
1/2✓ Branch 0 taken 7216 times.
✗ Branch 1 not taken.
|
7216 | || screen.flags11) |
| 9005 | 8376 | scr_has_flags |= SCRHAS_FLAGS; | |
| 9006 | |||
| 9007 |
2/2✓ Branch 0 taken 8318 times.
✓ Branch 1 taken 58 times.
|
8376 | if(screen.pattern) |
| 9008 | 58 | scr_has_flags |= SCRHAS_ENEMY; | |
| 9009 |
2/2✓ Branch 0 taken 7304 times.
✓ Branch 1 taken 74060 times.
|
81364 | else for(auto q = 0; q < 10; ++q) |
| 9010 | { | ||
| 9011 |
2/2✓ Branch 0 taken 73046 times.
✓ Branch 1 taken 1014 times.
|
74060 | if(screen.enemy[q]) |
| 9012 | { | ||
| 9013 | 1014 | scr_has_flags |= SCRHAS_ENEMY; | |
| 9014 | 1014 | break; | |
| 9015 | } | ||
| 9016 | 73046 | } | |
| 9017 | |||
| 9018 |
2/4✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8342 times.
|
16718 | if(screen.noreset || screen.nocarry |
| 9019 |
3/4✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8342 times.
✓ Branch 3 taken 34 times.
|
8376 | || screen.nextmap || screen.nextscr) |
| 9020 | 34 | scr_has_flags |= SCRHAS_CARRY; | |
| 9021 | |||
| 9022 |
3/4✓ Branch 0 taken 8354 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8354 times.
|
8376 | if(screen.script || screen.preloadscript) |
| 9023 | 22 | scr_has_flags |= SCRHAS_SCRIPT; | |
| 9024 |
2/2✓ Branch 0 taken 8354 times.
✓ Branch 1 taken 66832 times.
|
75186 | else for(auto q = 0; q < 8; ++q) |
| 9025 | { | ||
| 9026 |
1/2✓ Branch 0 taken 66832 times.
✗ Branch 1 not taken.
|
66832 | if(screen.screeninitd[q]) |
| 9027 | { | ||
| 9028 | ✗ | scr_has_flags |= SCRHAS_SCRIPT; | |
| 9029 | ✗ | break; | |
| 9030 | } | ||
| 9031 | 66832 | } | |
| 9032 | |||
| 9033 |
2/2✓ Branch 0 taken 5300 times.
✓ Branch 1 taken 683480 times.
|
688780 | for(auto q = 0; q < 128; ++q) |
| 9034 | { | ||
| 9035 |
1/2✓ Branch 0 taken 680404 times.
✗ Branch 1 not taken.
|
1363884 | if(screen.secretcombo[q] |
| 9036 |
2/2✓ Branch 0 taken 680410 times.
✓ Branch 1 taken 3070 times.
|
683480 | || screen.secretcset[q] |
| 9037 |
2/2✓ Branch 0 taken 680404 times.
✓ Branch 1 taken 6 times.
|
680410 | || screen.secretflag[q]) |
| 9038 | { | ||
| 9039 | 3076 | scr_has_flags |= SCRHAS_SECRETS; | |
| 9040 | 3076 | break; | |
| 9041 | } | ||
| 9042 | 680404 | } | |
| 9043 | |||
| 9044 |
2/2✓ Branch 0 taken 3020 times.
✓ Branch 1 taken 573888 times.
|
576908 | for(auto q = 0; q < 176; ++q) |
| 9045 | { | ||
| 9046 |
4/4✓ Branch 0 taken 568780 times.
✓ Branch 1 taken 5108 times.
✓ Branch 2 taken 568532 times.
✓ Branch 3 taken 12 times.
|
573888 | if(screen.data[q] || screen.cset[q] |
| 9047 |
2/2✓ Branch 0 taken 568544 times.
✓ Branch 1 taken 236 times.
|
568780 | || screen.sflag[q]) |
| 9048 | { | ||
| 9049 | 5356 | scr_has_flags |= SCRHAS_COMBOFLAG; | |
| 9050 | 5356 | break; | |
| 9051 | } | ||
| 9052 | 568532 | } | |
| 9053 | |||
| 9054 |
2/2✓ Branch 0 taken 6142 times.
✓ Branch 1 taken 2234 times.
|
8376 | if(screen.color || screen.csensitive != 1 |
| 9055 |
3/4✓ Branch 0 taken 6142 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6108 times.
✓ Branch 3 taken 34 times.
|
6142 | || screen.oceansfx || screen.bosssfx |
| 9056 |
2/4✓ Branch 0 taken 6108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6108 times.
|
6108 | || screen.secretsfx || screen.holdupsfx |
| 9057 | ✗ | || screen.timedwarptics || screen.screen_midi != -1 | |
| 9058 | ✗ | || screen.lens_layer || screen.lens_show || screen.lens_hide) | |
| 9059 | 8376 | scr_has_flags |= SCRHAS_MISC; | |
| 9060 | |||
| 9061 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_iputl(scr_has_flags,f)) |
| 9062 | ✗ | return qe_invalid; | |
| 9063 | |||
| 9064 | //Write stuff | ||
| 9065 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8376 times.
|
8376 | if(scr_has_flags & SCRHAS_ROOMDATA) |
| 9066 | { | ||
| 9067 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.guy,f)) |
| 9068 | ✗ | return qe_invalid; | |
| 9069 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_iputl(screen.guytile,f)) |
| 9070 | ✗ | return qe_invalid; | |
| 9071 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.guycs,f)) |
| 9072 | ✗ | return qe_invalid; | |
| 9073 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_iputw(screen.roomflags,f)) |
| 9074 | ✗ | return qe_invalid; | |
| 9075 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_iputw(screen.str,f)) |
| 9076 | ✗ | return qe_invalid; | |
| 9077 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.room,f)) |
| 9078 | ✗ | return qe_invalid; | |
| 9079 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_iputw(screen.catchall,f)) |
| 9080 | ✗ | return qe_invalid; | |
| 9081 | 8376 | } | |
| 9082 |
2/2✓ Branch 0 taken 7930 times.
✓ Branch 1 taken 446 times.
|
8376 | if(scr_has_flags & SCRHAS_ITEM) |
| 9083 | { | ||
| 9084 |
1/2✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
|
446 | if(!p_putc(screen.item,f)) |
| 9085 | ✗ | return qe_invalid; | |
| 9086 |
1/2✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
|
446 | if(!p_putc(screen.hasitem,f)) |
| 9087 | ✗ | return qe_invalid; | |
| 9088 |
1/2✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
|
446 | if(!p_putc(screen.itemx,f)) |
| 9089 | ✗ | return qe_invalid; | |
| 9090 |
1/2✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
|
446 | if(!p_putc(screen.itemy,f)) |
| 9091 | ✗ | return qe_invalid; | |
| 9092 | 446 | } | |
| 9093 |
2/2✓ Branch 0 taken 4002 times.
✓ Branch 1 taken 4374 times.
|
8376 | if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP)) |
| 9094 | { | ||
| 9095 |
1/2✓ Branch 0 taken 4374 times.
✗ Branch 1 not taken.
|
4374 | if(!p_iputw(screen.warpreturnc,f)) |
| 9096 | ✗ | return qe_invalid; | |
| 9097 | 4374 | } | |
| 9098 |
2/2✓ Branch 0 taken 8172 times.
✓ Branch 1 taken 204 times.
|
8376 | if(scr_has_flags & SCRHAS_TWARP) |
| 9099 | { | ||
| 9100 |
2/2✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
|
1020 | for(int32_t k=0; k<4; k++) |
| 9101 | { | ||
| 9102 |
1/2✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
|
816 | if(!p_putc(screen.tilewarptype[k],f)) |
| 9103 | ✗ | return qe_invalid; | |
| 9104 | 816 | } | |
| 9105 |
2/2✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
|
1020 | for(int32_t k=0; k<4; k++) |
| 9106 | { | ||
| 9107 |
1/2✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
|
816 | if(!p_iputw(screen.tilewarpdmap[k],f)) |
| 9108 | ✗ | return qe_invalid; | |
| 9109 | 816 | } | |
| 9110 | |||
| 9111 |
2/2✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
|
1020 | for(int32_t k=0; k<4; k++) |
| 9112 | { | ||
| 9113 |
1/2✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
|
816 | if(!p_putc(screen.tilewarpscr[k],f)) |
| 9114 | ✗ | return qe_invalid; | |
| 9115 | 816 | } | |
| 9116 | |||
| 9117 |
1/2✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
|
204 | if(!p_putc(screen.tilewarpoverlayflags,f)) |
| 9118 | ✗ | return qe_invalid; | |
| 9119 | 204 | } | |
| 9120 |
2/2✓ Branch 0 taken 4070 times.
✓ Branch 1 taken 4306 times.
|
8376 | if(scr_has_flags & SCRHAS_SWARP) |
| 9121 | { | ||
| 9122 |
2/2✓ Branch 0 taken 17224 times.
✓ Branch 1 taken 4306 times.
|
21530 | for(int32_t k=0; k<4; k++) |
| 9123 | { | ||
| 9124 |
1/2✓ Branch 0 taken 17224 times.
✗ Branch 1 not taken.
|
17224 | if(!p_putc(screen.sidewarptype[k],f)) |
| 9125 | ✗ | return qe_invalid; | |
| 9126 | 17224 | } | |
| 9127 |
2/2✓ Branch 0 taken 17224 times.
✓ Branch 1 taken 4306 times.
|
21530 | for(int32_t k=0; k<4; k++) |
| 9128 | { | ||
| 9129 |
1/2✓ Branch 0 taken 17224 times.
✗ Branch 1 not taken.
|
17224 | if(!p_iputw(screen.sidewarpdmap[k],f)) |
| 9130 | ✗ | return qe_invalid; | |
| 9131 | 17224 | } | |
| 9132 | |||
| 9133 |
2/2✓ Branch 0 taken 17224 times.
✓ Branch 1 taken 4306 times.
|
21530 | for(int32_t k=0; k<4; k++) |
| 9134 | { | ||
| 9135 |
1/2✓ Branch 0 taken 17224 times.
✗ Branch 1 not taken.
|
17224 | if(!p_putc(screen.sidewarpscr[k],f)) |
| 9136 | ✗ | return qe_invalid; | |
| 9137 | 17224 | } | |
| 9138 | |||
| 9139 |
1/2✓ Branch 0 taken 4306 times.
✗ Branch 1 not taken.
|
4306 | if(!p_putc(screen.sidewarpoverlayflags,f)) |
| 9140 | ✗ | return qe_invalid; | |
| 9141 |
1/2✓ Branch 0 taken 4306 times.
✗ Branch 1 not taken.
|
4306 | if(!p_putc(screen.sidewarpindex,f)) |
| 9142 | ✗ | return qe_invalid; | |
| 9143 | 4306 | } | |
| 9144 |
2/2✓ Branch 0 taken 7550 times.
✓ Branch 1 taken 826 times.
|
8376 | if(scr_has_flags & SCRHAS_WARPRET) |
| 9145 | { | ||
| 9146 |
2/2✓ Branch 0 taken 3304 times.
✓ Branch 1 taken 826 times.
|
4130 | for(int32_t k=0; k<4; k++) |
| 9147 | { | ||
| 9148 |
1/2✓ Branch 0 taken 3304 times.
✗ Branch 1 not taken.
|
3304 | if(!p_putc(screen.warpreturnx[k],f)) |
| 9149 | ✗ | return qe_invalid; | |
| 9150 | 3304 | } | |
| 9151 |
2/2✓ Branch 0 taken 3304 times.
✓ Branch 1 taken 826 times.
|
4130 | for(int32_t k=0; k<4; k++) |
| 9152 | { | ||
| 9153 |
1/2✓ Branch 0 taken 3304 times.
✗ Branch 1 not taken.
|
3304 | if(!p_putc(screen.warpreturny[k],f)) |
| 9154 | ✗ | return qe_invalid; | |
| 9155 | 3304 | } | |
| 9156 |
1/2✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
|
826 | if(!p_putc(screen.warparrivalx,f)) |
| 9157 | ✗ | return qe_invalid; | |
| 9158 |
1/2✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
|
826 | if(!p_putc(screen.warparrivaly,f)) |
| 9159 | ✗ | return qe_invalid; | |
| 9160 | 826 | } | |
| 9161 |
2/2✓ Branch 0 taken 7410 times.
✓ Branch 1 taken 966 times.
|
8376 | if(scr_has_flags & SCRHAS_LAYERS) |
| 9162 | { | ||
| 9163 |
2/2✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 966 times.
|
6762 | for(int32_t k=0; k<6; k++) |
| 9164 | { | ||
| 9165 |
1/2✓ Branch 0 taken 5796 times.
✗ Branch 1 not taken.
|
5796 | if(!p_putc(screen.layermap[k],f)) |
| 9166 | ✗ | return qe_invalid; | |
| 9167 | 5796 | } | |
| 9168 |
2/2✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 966 times.
|
6762 | for(int32_t k=0; k<6; k++) |
| 9169 | { | ||
| 9170 |
1/2✓ Branch 0 taken 5796 times.
✗ Branch 1 not taken.
|
5796 | if(!p_putc(screen.layerscreen[k],f)) |
| 9171 | ✗ | return qe_invalid; | |
| 9172 | 5796 | } | |
| 9173 |
2/2✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 966 times.
|
6762 | for(int32_t k=0; k<6; k++) |
| 9174 | { | ||
| 9175 |
1/2✓ Branch 0 taken 5796 times.
✗ Branch 1 not taken.
|
5796 | if(!p_putc(screen.layeropacity[k],f)) |
| 9176 | ✗ | return qe_invalid; | |
| 9177 | 5796 | } | |
| 9178 |
1/2✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
|
966 | if(!p_putc(screen.hidelayers,f)) |
| 9179 | ✗ | return qe_invalid; | |
| 9180 |
1/2✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
|
966 | if(!p_putc(screen.hidescriptlayers,f)) |
| 9181 | ✗ | return qe_invalid; | |
| 9182 | 966 | } | |
| 9183 |
2/2✓ Branch 0 taken 8366 times.
✓ Branch 1 taken 10 times.
|
8376 | if(scr_has_flags & SCRHAS_MAZE) |
| 9184 | { | ||
| 9185 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 10 times.
|
50 | for(int32_t k=0; k<4; k++) |
| 9186 | { | ||
| 9187 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | if(!p_putc(screen.path[k],f)) |
| 9188 | ✗ | return qe_invalid; | |
| 9189 | 40 | } | |
| 9190 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(screen.exitdir,f)) |
| 9191 | ✗ | return qe_invalid; | |
| 9192 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(screen.maze_transition_wipe,f)) |
| 9193 | ✗ | return qe_invalid; | |
| 9194 | 10 | } | |
| 9195 |
2/2✓ Branch 0 taken 196 times.
✓ Branch 1 taken 8180 times.
|
8376 | if(scr_has_flags & SCRHAS_D_S_U) |
| 9196 | { | ||
| 9197 |
1/2✓ Branch 0 taken 8180 times.
✗ Branch 1 not taken.
|
8180 | if(!p_iputw(screen.door_combo_set,f)) |
| 9198 | ✗ | return qe_invalid; | |
| 9199 |
2/2✓ Branch 0 taken 32720 times.
✓ Branch 1 taken 8180 times.
|
40900 | for(int32_t k=0; k<4; k++) |
| 9200 | { | ||
| 9201 |
1/2✓ Branch 0 taken 32720 times.
✗ Branch 1 not taken.
|
32720 | if(!p_putc(screen.door[k],f)) |
| 9202 | ✗ | return qe_invalid; | |
| 9203 | 32720 | } | |
| 9204 |
1/2✓ Branch 0 taken 8180 times.
✗ Branch 1 not taken.
|
8180 | if(!p_putc(screen.stairx,f)) |
| 9205 | ✗ | return qe_invalid; | |
| 9206 |
1/2✓ Branch 0 taken 8180 times.
✗ Branch 1 not taken.
|
8180 | if(!p_putc(screen.stairy,f)) |
| 9207 | ✗ | return qe_invalid; | |
| 9208 |
1/2✓ Branch 0 taken 8180 times.
✗ Branch 1 not taken.
|
8180 | if(!p_iputw(screen.undercombo,f)) |
| 9209 | ✗ | return qe_invalid; | |
| 9210 |
1/2✓ Branch 0 taken 8180 times.
✗ Branch 1 not taken.
|
8180 | if(!p_putc(screen.undercset,f)) |
| 9211 | ✗ | return qe_invalid; | |
| 9212 | 8180 | } | |
| 9213 |
2/2✓ Branch 0 taken 7082 times.
✓ Branch 1 taken 1294 times.
|
8376 | if(scr_has_flags & SCRHAS_FLAGS) |
| 9214 | { | ||
| 9215 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags,f)) |
| 9216 | ✗ | return qe_invalid; | |
| 9217 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags2,f)) |
| 9218 | ✗ | return qe_invalid; | |
| 9219 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags3,f)) |
| 9220 | ✗ | return qe_invalid; | |
| 9221 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags4,f)) |
| 9222 | ✗ | return qe_invalid; | |
| 9223 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags5,f)) |
| 9224 | ✗ | return qe_invalid; | |
| 9225 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags6,f)) |
| 9226 | ✗ | return qe_invalid; | |
| 9227 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags7,f)) |
| 9228 | ✗ | return qe_invalid; | |
| 9229 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags8,f)) |
| 9230 | ✗ | return qe_invalid; | |
| 9231 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags9,f)) |
| 9232 | ✗ | return qe_invalid; | |
| 9233 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags10,f)) |
| 9234 | ✗ | return qe_invalid; | |
| 9235 |
1/2✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
|
1294 | if(!p_putc(screen.flags11,f)) |
| 9236 | ✗ | return qe_invalid; | |
| 9237 | 1294 | } | |
| 9238 |
2/2✓ Branch 0 taken 7304 times.
✓ Branch 1 taken 1072 times.
|
8376 | if(scr_has_flags & SCRHAS_ENEMY) |
| 9239 | { | ||
| 9240 |
2/2✓ Branch 0 taken 10720 times.
✓ Branch 1 taken 1072 times.
|
11792 | for(int32_t k=0; k<10; k++) |
| 9241 | { | ||
| 9242 |
1/2✓ Branch 0 taken 10720 times.
✗ Branch 1 not taken.
|
10720 | if(!p_iputw(screen.enemy[k],f)) |
| 9243 | ✗ | return qe_invalid; | |
| 9244 | 10720 | } | |
| 9245 |
1/2✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
|
1072 | if(!p_putc(screen.pattern,f)) |
| 9246 | ✗ | return qe_invalid; | |
| 9247 | 1072 | } | |
| 9248 |
2/2✓ Branch 0 taken 8342 times.
✓ Branch 1 taken 34 times.
|
8376 | if(scr_has_flags & SCRHAS_CARRY) |
| 9249 | { | ||
| 9250 |
1/2✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
|
34 | if(!p_iputw(screen.noreset,f)) |
| 9251 | ✗ | return qe_invalid; | |
| 9252 |
1/2✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
|
34 | if(!p_iputw(screen.nocarry,f)) |
| 9253 | ✗ | return qe_invalid; | |
| 9254 |
1/2✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
|
34 | if(!p_putc(screen.nextmap,f)) |
| 9255 | ✗ | return qe_invalid; | |
| 9256 |
1/2✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
|
34 | if(!p_putc(screen.nextscr,f)) |
| 9257 | ✗ | return qe_invalid; | |
| 9258 | 34 | } | |
| 9259 |
2/2✓ Branch 0 taken 8354 times.
✓ Branch 1 taken 22 times.
|
8376 | if(scr_has_flags & SCRHAS_SCRIPT) |
| 9260 | { | ||
| 9261 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | if(!p_iputw(screen.script,f)) |
| 9262 | ✗ | return qe_invalid; | |
| 9263 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | if(!p_putc(screen.preloadscript,f)) |
| 9264 | ✗ | return qe_invalid; | |
| 9265 |
2/2✓ Branch 0 taken 176 times.
✓ Branch 1 taken 22 times.
|
198 | for ( int32_t q = 0; q < 8; q++ ) |
| 9266 | { | ||
| 9267 |
1/2✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
|
176 | if(!p_iputl(screen.screeninitd[q],f)) |
| 9268 | ✗ | return qe_invalid; | |
| 9269 | 176 | } | |
| 9270 | 22 | } | |
| 9271 |
2/2✓ Branch 0 taken 5300 times.
✓ Branch 1 taken 3076 times.
|
8376 | if(scr_has_flags & SCRHAS_SECRETS) |
| 9272 | { | ||
| 9273 |
2/2✓ Branch 0 taken 393728 times.
✓ Branch 1 taken 3076 times.
|
396804 | for(int32_t k=0; k<128; k++) |
| 9274 | { | ||
| 9275 |
1/2✓ Branch 0 taken 393728 times.
✗ Branch 1 not taken.
|
393728 | if(!p_iputw(screen.secretcombo[k],f)) |
| 9276 | ✗ | return qe_invalid; | |
| 9277 | 393728 | } | |
| 9278 | |||
| 9279 |
2/2✓ Branch 0 taken 393728 times.
✓ Branch 1 taken 3076 times.
|
396804 | for(int32_t k=0; k<128; k++) |
| 9280 | { | ||
| 9281 |
1/2✓ Branch 0 taken 393728 times.
✗ Branch 1 not taken.
|
393728 | if(!p_putc(screen.secretcset[k],f)) |
| 9282 | ✗ | return qe_invalid; | |
| 9283 | 393728 | } | |
| 9284 | |||
| 9285 |
2/2✓ Branch 0 taken 393728 times.
✓ Branch 1 taken 3076 times.
|
396804 | for(int32_t k=0; k<128; k++) |
| 9286 | { | ||
| 9287 |
1/2✓ Branch 0 taken 393728 times.
✗ Branch 1 not taken.
|
393728 | if(!p_putc(screen.secretflag[k],f)) |
| 9288 | ✗ | return qe_invalid; | |
| 9289 | 393728 | } | |
| 9290 | 3076 | } | |
| 9291 |
2/2✓ Branch 0 taken 3020 times.
✓ Branch 1 taken 5356 times.
|
8376 | if(scr_has_flags & SCRHAS_COMBOFLAG) |
| 9292 | { | ||
| 9293 |
2/2✓ Branch 0 taken 942656 times.
✓ Branch 1 taken 5356 times.
|
948012 | for(int32_t k=0; k<176; ++k) |
| 9294 | { | ||
| 9295 |
1/2✓ Branch 0 taken 942656 times.
✗ Branch 1 not taken.
|
942656 | if(!p_iputw(screen.data[k],f)) |
| 9296 | ✗ | return qe_invalid; | |
| 9297 | 942656 | } | |
| 9298 |
2/2✓ Branch 0 taken 942656 times.
✓ Branch 1 taken 5356 times.
|
948012 | for(int32_t k=0; k<176; ++k) |
| 9299 | { | ||
| 9300 |
1/2✓ Branch 0 taken 942656 times.
✗ Branch 1 not taken.
|
942656 | if(!p_putc(screen.sflag[k],f)) |
| 9301 | ✗ | return qe_invalid; | |
| 9302 | 942656 | } | |
| 9303 |
2/2✓ Branch 0 taken 942656 times.
✓ Branch 1 taken 5356 times.
|
948012 | for(int32_t k=0; k<176; ++k) |
| 9304 | { | ||
| 9305 |
1/2✓ Branch 0 taken 942656 times.
✗ Branch 1 not taken.
|
942656 | if(!p_putc(screen.cset[k],f)) |
| 9306 | ✗ | return qe_invalid; | |
| 9307 | 942656 | } | |
| 9308 | 5356 | } | |
| 9309 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8376 times.
|
8376 | if(scr_has_flags & SCRHAS_MISC) |
| 9310 | { | ||
| 9311 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_iputw(screen.color,f)) |
| 9312 | ✗ | return qe_invalid; | |
| 9313 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.csensitive,f)) |
| 9314 | ✗ | return qe_invalid; | |
| 9315 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.oceansfx,f)) |
| 9316 | ✗ | return qe_invalid; | |
| 9317 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.bosssfx,f)) |
| 9318 | ✗ | return qe_invalid; | |
| 9319 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.secretsfx,f)) |
| 9320 | ✗ | return qe_invalid; | |
| 9321 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.holdupsfx,f)) |
| 9322 | ✗ | return qe_invalid; | |
| 9323 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_iputw(screen.timedwarptics,f)) |
| 9324 | ✗ | return qe_invalid; | |
| 9325 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_iputw(screen.screen_midi,f)) |
| 9326 | ✗ | return qe_invalid; | |
| 9327 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.lens_layer,f)) |
| 9328 | ✗ | return qe_invalid; | |
| 9329 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.lens_show,f)) |
| 9330 | ✗ | return qe_invalid; | |
| 9331 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putc(screen.lens_hide,f)) |
| 9332 | ✗ | return qe_invalid; | |
| 9333 | 8376 | } | |
| 9334 | |||
| 9335 | 8376 | dword numffc = screen.numFFC(); | |
| 9336 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_iputw(numffc,f)) |
| 9337 | ✗ | return qe_invalid; | |
| 9338 |
2/2✓ Branch 0 taken 245678 times.
✓ Branch 1 taken 8376 times.
|
254054 | for(int32_t k=0; k<numffc; ++k) |
| 9339 | { | ||
| 9340 | 245678 | ffcdata const& tempffc = screen.ffcs[k]; | |
| 9341 | |||
| 9342 |
1/2✓ Branch 0 taken 245678 times.
✗ Branch 1 not taken.
|
245678 | if(!p_iputw(tempffc.data,f)) |
| 9343 | ✗ | return qe_invalid; | |
| 9344 | |||
| 9345 |
2/2✓ Branch 0 taken 2314 times.
✓ Branch 1 taken 243364 times.
|
245678 | if(!tempffc.data) //don't save the rest of the ffc |
| 9346 | 243364 | continue; | |
| 9347 | |||
| 9348 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_putc(tempffc.cset,f)) |
| 9349 | ✗ | return qe_invalid; | |
| 9350 | |||
| 9351 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputw(tempffc.delay,f)) |
| 9352 | ✗ | return qe_invalid; | |
| 9353 | |||
| 9354 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputzf(tempffc.x,f)) |
| 9355 | ✗ | return qe_invalid; | |
| 9356 | |||
| 9357 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputzf(tempffc.y,f)) |
| 9358 | ✗ | return qe_invalid; | |
| 9359 | |||
| 9360 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputzf(tempffc.vx,f)) |
| 9361 | ✗ | return qe_invalid; | |
| 9362 | |||
| 9363 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputzf(tempffc.vy,f)) |
| 9364 | ✗ | return qe_invalid; | |
| 9365 | |||
| 9366 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputzf(tempffc.ax,f)) |
| 9367 | ✗ | return qe_invalid; | |
| 9368 | |||
| 9369 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputzf(tempffc.ay,f)) |
| 9370 | ✗ | return qe_invalid; | |
| 9371 | |||
| 9372 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_putc(tempffc.link,f)) |
| 9373 | ✗ | return qe_invalid; | |
| 9374 | |||
| 9375 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputl(tempffc.hit_width,f)) |
| 9376 | ✗ | return qe_invalid; | |
| 9377 | |||
| 9378 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputl(tempffc.hit_height,f)) |
| 9379 | ✗ | return qe_invalid; | |
| 9380 | |||
| 9381 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_putc(tempffc.txsz,f)) |
| 9382 | ✗ | return qe_invalid; | |
| 9383 | |||
| 9384 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_putc(tempffc.tysz,f)) |
| 9385 | ✗ | return qe_invalid; | |
| 9386 | |||
| 9387 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputl(tempffc.flags,f)) |
| 9388 | ✗ | return qe_invalid; | |
| 9389 | |||
| 9390 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_iputw(tempffc.script,f)) |
| 9391 | ✗ | return qe_invalid; | |
| 9392 | |||
| 9393 |
2/2✓ Branch 0 taken 18512 times.
✓ Branch 1 taken 2314 times.
|
20826 | for(auto q = 0; q < 8; ++q) |
| 9394 | { | ||
| 9395 |
1/2✓ Branch 0 taken 18512 times.
✗ Branch 1 not taken.
|
18512 | if(!p_iputl(tempffc.initd[q],f)) |
| 9396 | ✗ | return qe_invalid; | |
| 9397 | 18512 | } | |
| 9398 | |||
| 9399 |
1/2✓ Branch 0 taken 2314 times.
✗ Branch 1 not taken.
|
2314 | if(!p_putc(tempffc.layer,f)) |
| 9400 | ✗ | return qe_invalid; | |
| 9401 | 2314 | } | |
| 9402 | |||
| 9403 |
1/2✓ Branch 0 taken 8376 times.
✗ Branch 1 not taken.
|
8376 | if(!p_putlstr(screen.usr_notes, f)) |
| 9404 | ✗ | return qe_invalid; | |
| 9405 | |||
| 9406 | 8376 | return qe_OK; | |
| 9407 | 12784 | } | |
| 9408 | |||
| 9409 | 9 | int32_t writemaps(PACKFILE *f, zquestheader *) | |
| 9410 | { | ||
| 9411 | 9 | dword section_id=ID_MAPS; | |
| 9412 | 9 | dword section_version=V_MAPS; | |
| 9413 | 9 | dword section_size = 0; | |
| 9414 | |||
| 9415 | //section id | ||
| 9416 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 9417 | { | ||
| 9418 | ✗ | new_return(1); | |
| 9419 | } | ||
| 9420 | |||
| 9421 | //section version info | ||
| 9422 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 9423 | { | ||
| 9424 | ✗ | new_return(2); | |
| 9425 | } | ||
| 9426 | |||
| 9427 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 9428 | { | ||
| 9429 | ✗ | new_return(3); | |
| 9430 | } | ||
| 9431 | |||
| 9432 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 9433 | { | ||
| 9434 | 18 | fake_pack_writing=(writecycle==0); | |
| 9435 | |||
| 9436 | //section size | ||
| 9437 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 9438 | { | ||
| 9439 | ✗ | new_return(4); | |
| 9440 | } | ||
| 9441 | |||
| 9442 | 18 | writesize=0; | |
| 9443 | |||
| 9444 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(map_count,f)) |
| 9445 | { | ||
| 9446 | ✗ | new_return(5); | |
| 9447 | } | ||
| 9448 | 18 | map_autolayers.resize(map_count*6); | |
| 9449 |
4/4✓ Branch 0 taken 18 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 18 times.
|
118 | for(int32_t i=0; i<map_count && i<MAXMAPS; i++) |
| 9450 | { | ||
| 9451 | 100 | byte valid = 0; | |
| 9452 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1282 times.
|
1288 | for(int32_t j=0; j<MAPSCRS; j++) |
| 9453 | { | ||
| 9454 |
1/2✓ Branch 0 taken 1282 times.
✗ Branch 1 not taken.
|
1282 | if((i*MAPSCRS+j)>=int32_t(TheMaps.size())) |
| 9455 | ✗ | break; | |
| 9456 | 1282 | mapscr& screen=TheMaps.at(i*MAPSCRS+j); | |
| 9457 |
2/2✓ Branch 0 taken 94 times.
✓ Branch 1 taken 1188 times.
|
1282 | if (screen.is_valid()) |
| 9458 | { | ||
| 9459 | 94 | valid = 1; | |
| 9460 | 94 | break; | |
| 9461 | } | ||
| 9462 | 1188 | } | |
| 9463 |
1/2✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
|
100 | if(!p_putc(valid,f)) |
| 9464 | { | ||
| 9465 | ✗ | new_return(6); | |
| 9466 | } | ||
| 9467 |
2/2✓ Branch 0 taken 94 times.
✓ Branch 1 taken 6 times.
|
100 | if(!valid) continue; |
| 9468 | |||
| 9469 | { //per-map info | ||
| 9470 |
2/2✓ Branch 0 taken 564 times.
✓ Branch 1 taken 94 times.
|
658 | for(int q = 0; q < 6; ++q) |
| 9471 | { | ||
| 9472 | 564 | size_t ind = i*6+q; | |
| 9473 |
1/2✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
|
564 | if(!p_iputw(map_autolayers[ind],f)) |
| 9474 | ✗ | new_return(7); | |
| 9475 | 564 | } | |
| 9476 | |||
| 9477 |
2/2✓ Branch 0 taken 752 times.
✓ Branch 1 taken 94 times.
|
846 | for(int32_t j=0; j<8; j++) |
| 9478 | { | ||
| 9479 |
2/2✓ Branch 0 taken 752 times.
✓ Branch 1 taken 6016 times.
|
6768 | for(int32_t k=0; k<8; k++) |
| 9480 | { | ||
| 9481 |
1/2✓ Branch 0 taken 6016 times.
✗ Branch 1 not taken.
|
6016 | if(!p_putc(Regions[i].region_ids[j][k],f)) |
| 9482 | { | ||
| 9483 | ✗ | new_return(8); | |
| 9484 | } | ||
| 9485 | 6016 | } | |
| 9486 | 752 | } | |
| 9487 | } | ||
| 9488 | |||
| 9489 |
2/2✓ Branch 0 taken 12784 times.
✓ Branch 1 taken 94 times.
|
12878 | for(int32_t j=0; j<MAPSCRS; j++) |
| 9490 | 12784 | writemapscreen(f,i,j); | |
| 9491 | 94 | } | |
| 9492 | |||
| 9493 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 9494 | { | ||
| 9495 | 9 | section_size=writesize; | |
| 9496 | 9 | } | |
| 9497 | 18 | } | |
| 9498 | |||
| 9499 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 9500 | { | ||
| 9501 | char ebuf[80]; | ||
| 9502 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 9503 | ✗ | jwin_alert("Error: writemaps()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 9504 | ✗ | } | |
| 9505 | |||
| 9506 | 9 | new_return(0); | |
| 9507 | } | ||
| 9508 | |||
| 9509 | ✗ | int32_t writecombo_loop(PACKFILE *f, word section_version, newcombo const& tmp_cmb) | |
| 9510 | { | ||
| 9511 | //Check what needs writing | ||
| 9512 | ✗ | byte combo_has_flags = 0; | |
| 9513 | 1029708 | for(auto q = 0; q < 8; ++q) | |
| 9514 | { | ||
| 9515 | 2059416 | if(tmp_cmb.attribytes[q] || tmp_cmb.attrishorts[q] | |
| 9516 | 1029708 | || (q < 4 && tmp_cmb.attributes[q])) | |
| 9517 | { | ||
| 9518 | ✗ | combo_has_flags |= CHAS_ATTRIB; | |
| 9519 | ✗ | break; | |
| 9520 | } | ||
| 9521 | 1029708 | } | |
| 9522 |
3/4✓ Branch 0 taken 258514 times.
✓ Branch 1 taken 258514 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 258446 times.
|
258446 | if (tmp_cmb.triggerflags[0] || tmp_cmb.triggerflags[1] |
| 9523 |
3/4✓ Branch 0 taken 258512 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 258512 times.
✗ Branch 3 not taken.
|
258514 | || tmp_cmb.triggerflags[2] || tmp_cmb.triggerflags[3] |
| 9524 |
3/4✓ Branch 0 taken 258510 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 258510 times.
✗ Branch 3 not taken.
|
258512 | || tmp_cmb.triggerflags[4] || tmp_cmb.triggerflags[5] |
| 9525 |
2/4✓ Branch 0 taken 258510 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258510 times.
✗ Branch 3 not taken.
|
258510 | || tmp_cmb.triggerlevel || tmp_cmb.trig_lstate |
| 9526 |
2/4✓ Branch 0 taken 258510 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258510 times.
✗ Branch 3 not taken.
|
258510 | || tmp_cmb.trig_gstate || tmp_cmb.trig_statetime |
| 9527 |
2/4✓ Branch 0 taken 258510 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258510 times.
✗ Branch 3 not taken.
|
258510 | || tmp_cmb.triggerbtn || tmp_cmb.triggeritem |
| 9528 |
2/4✓ Branch 0 taken 258510 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258510 times.
✗ Branch 3 not taken.
|
258510 | || tmp_cmb.trigtimer || tmp_cmb.trigsfx |
| 9529 |
4/4✓ Branch 0 taken 258448 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 258446 times.
✓ Branch 3 taken 2 times.
|
258510 | || tmp_cmb.trigchange || tmp_cmb.trigprox |
| 9530 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.trigctr || tmp_cmb.trigctramnt |
| 9531 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.triglbeam || tmp_cmb.trigcschange |
| 9532 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.spawnitem || tmp_cmb.spawnenemy |
| 9533 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.exstate > -1 || tmp_cmb.spawnip |
| 9534 |
1/2✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
|
258446 | || tmp_cmb.exdoor_dir > -1 |
| 9535 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.trigcopycat || tmp_cmb.trigcooldown |
| 9536 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.trig_genscr || tmp_cmb.trig_group |
| 9537 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.trig_group_val || tmp_cmb.trig_levelitems |
| 9538 |
1/2✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
|
258446 | || tmp_cmb.trigdmlevel > -1 |
| 9539 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.triglvlpalette > -1 || tmp_cmb.trigbosspalette > -1 |
| 9540 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.trigquaketime > -1 || tmp_cmb.trigwavytime > -1 |
| 9541 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.trig_swjinxtime > -2 || tmp_cmb.trig_itmjinxtime > -2 |
| 9542 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.trig_stuntime > -2 || tmp_cmb.trig_bunnytime > -2 |
| 9543 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.trig_pushtime != 8 || tmp_cmb.trig_shieldjinxtime > -2 |
| 9544 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.prompt_cid || tmp_cmb.prompt_cs |
| 9545 |
2/4✓ Branch 0 taken 258446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258446 times.
✗ Branch 3 not taken.
|
258446 | || tmp_cmb.prompt_x != 12 || tmp_cmb.prompt_y != -8) |
| 9546 | 258582 | combo_has_flags |= CHAS_TRIG; | |
| 9547 |
2/2✓ Branch 0 taken 775338 times.
✓ Branch 1 taken 258446 times.
|
1033784 | else for(int q = 0; q < 3; ++q) |
| 9548 |
1/2✓ Branch 0 taken 775338 times.
✗ Branch 1 not taken.
|
775338 | if(tmp_cmb.trigtint[q]) |
| 9549 | ✗ | combo_has_flags |= CHAS_TRIG; | |
| 9550 |
4/4✓ Branch 0 taken 258636 times.
✓ Branch 1 taken 258392 times.
✓ Branch 2 taken 258102 times.
✓ Branch 3 taken 534 times.
|
517028 | if(tmp_cmb.usrflags || tmp_cmb.genflags) |
| 9551 | 516494 | combo_has_flags |= CHAS_FLAG; | |
| 9552 |
6/6✓ Branch 0 taken 251806 times.
✓ Branch 1 taken 250982 times.
✓ Branch 2 taken 231382 times.
✓ Branch 3 taken 20424 times.
✓ Branch 4 taken 243350 times.
✓ Branch 5 taken 12086 times.
|
232088 | if(tmp_cmb.frames || tmp_cmb.speed || tmp_cmb.nextcombo |
| 9553 |
6/6✓ Branch 0 taken 231358 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 231320 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 231264 times.
✓ Branch 5 taken 56 times.
|
231382 | || tmp_cmb.nextcset || tmp_cmb.skipanim || tmp_cmb.skipanimy |
| 9554 |
1/2✓ Branch 0 taken 231264 times.
✗ Branch 1 not taken.
|
231264 | || tmp_cmb.animflags) |
| 9555 | 514874 | combo_has_flags |= CHAS_ANIM; | |
| 9556 |
4/4✓ Branch 0 taken 258906 times.
✓ Branch 1 taken 218646 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 258900 times.
|
40260 | if(tmp_cmb.script || tmp_cmb.label.size()) |
| 9557 | 218652 | combo_has_flags |= CHAS_SCRIPT; | |
| 9558 |
2/2✓ Branch 0 taken 2071200 times.
✓ Branch 1 taken 258900 times.
|
2330100 | else for(auto q = 0; q < 8; ++q) |
| 9559 | { | ||
| 9560 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2071200 times.
|
2071200 | if(tmp_cmb.initd[q]) |
| 9561 | { | ||
| 9562 | ✗ | combo_has_flags |= CHAS_SCRIPT; | |
| 9563 | ✗ | break; | |
| 9564 | } | ||
| 9565 | 2071200 | } | |
| 9566 |
6/6✓ Branch 0 taken 176920 times.
✓ Branch 1 taken 300632 times.
✓ Branch 2 taken 176408 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 218646 times.
✓ Branch 5 taken 42238 times.
|
653960 | if(tmp_cmb.o_tile || tmp_cmb.flip || tmp_cmb.walk != 0xF0 |
| 9567 |
2/4✓ Branch 0 taken 176408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 176408 times.
✗ Branch 3 not taken.
|
176408 | || tmp_cmb.type || tmp_cmb.csets) |
| 9568 | 519790 | combo_has_flags |= CHAS_BASIC; | |
| 9569 |
3/4✓ Branch 0 taken 258898 times.
✓ Branch 1 taken 134162 times.
✓ Branch 2 taken 258898 times.
✗ Branch 3 not taken.
|
383632 | if(tmp_cmb.liftcmb || tmp_cmb.liftcs || tmp_cmb.liftdmg |
| 9570 |
3/6✓ Branch 0 taken 258898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 258898 times.
✗ Branch 5 not taken.
|
258898 | || tmp_cmb.liftlvl || tmp_cmb.liftitm || tmp_cmb.liftflags |
| 9571 |
4/6✓ Branch 0 taken 258896 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 258896 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 258896 times.
✗ Branch 5 not taken.
|
258898 | || tmp_cmb.liftgfx || tmp_cmb.liftsprite || tmp_cmb.liftsfx |
| 9572 |
2/4✓ Branch 0 taken 258896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258896 times.
✗ Branch 3 not taken.
|
258896 | || tmp_cmb.liftundercmb || tmp_cmb.liftundercs |
| 9573 |
2/4✓ Branch 0 taken 258896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258896 times.
✗ Branch 3 not taken.
|
258896 | || tmp_cmb.liftbreaksprite!=-1 || tmp_cmb.liftbreaksfx |
| 9574 |
2/4✓ Branch 0 taken 258896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258896 times.
✗ Branch 3 not taken.
|
258896 | || tmp_cmb.lifthei!=8 || tmp_cmb.lifttime!=16 |
| 9575 |
1/2✓ Branch 0 taken 258896 times.
✗ Branch 1 not taken.
|
258896 | || tmp_cmb.lift_parent_item) |
| 9576 | 393060 | combo_has_flags |= CHAS_LIFT; | |
| 9577 |
3/4✓ Branch 0 taken 258906 times.
✓ Branch 1 taken 134154 times.
✓ Branch 2 taken 258906 times.
✗ Branch 3 not taken.
|
649766 | if(tmp_cmb.speed_mult != 1 || tmp_cmb.speed_div != 1 || tmp_cmb.speed_add |
| 9578 |
7/10✓ Branch 0 taken 258906 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258902 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 258898 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 258898 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 258898 times.
✗ Branch 9 not taken.
|
258906 | || tmp_cmb.sfx_appear || tmp_cmb.sfx_disappear || tmp_cmb.sfx_loop || tmp_cmb.sfx_walking || tmp_cmb.sfx_standing |
| 9579 |
5/10✓ Branch 0 taken 258898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 258898 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 258898 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 258898 times.
✗ Branch 9 not taken.
|
258898 | || tmp_cmb.spr_appear || tmp_cmb.spr_disappear || tmp_cmb.spr_walking || tmp_cmb.spr_standing || tmp_cmb.sfx_tap |
| 9580 |
6/10✓ Branch 0 taken 258898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256706 times.
✓ Branch 3 taken 2192 times.
✓ Branch 4 taken 256706 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 256706 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 256706 times.
✗ Branch 9 not taken.
|
258898 | || tmp_cmb.sfx_landing || tmp_cmb.spr_falling || tmp_cmb.spr_drowning || tmp_cmb.spr_lava_drowning || tmp_cmb.sfx_falling |
| 9581 |
2/4✓ Branch 0 taken 256706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256706 times.
✗ Branch 3 not taken.
|
256706 | || tmp_cmb.sfx_drowning || tmp_cmb.sfx_lava_drowning) |
| 9582 | 393060 | combo_has_flags |= CHAS_GENERAL; | |
| 9583 | |||
| 9584 |
2/2✓ Branch 0 taken 258906 times.
✓ Branch 1 taken 134154 times.
|
393060 | if(!p_putc(combo_has_flags,f)) |
| 9585 | { | ||
| 9586 | 134154 | return 50; | |
| 9587 | } | ||
| 9588 |
2/2✓ Branch 0 taken 82498 times.
✓ Branch 1 taken 176408 times.
|
258906 | if(!combo_has_flags) return 0; //Valid, done reading |
| 9589 | //Write the combo | ||
| 9590 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 82498 times.
|
82498 | if(combo_has_flags&CHAS_BASIC) |
| 9591 | { | ||
| 9592 |
1/2✓ Branch 0 taken 82498 times.
✗ Branch 1 not taken.
|
82498 | if(!p_iputl(tmp_cmb.o_tile,f)) |
| 9593 | ✗ | return 6; | |
| 9594 | |||
| 9595 |
1/2✓ Branch 0 taken 82498 times.
✗ Branch 1 not taken.
|
82498 | if(!p_putc(tmp_cmb.flip,f)) |
| 9596 | ✗ | return 7; | |
| 9597 | |||
| 9598 |
1/2✓ Branch 0 taken 82498 times.
✗ Branch 1 not taken.
|
82498 | if(!p_putc(tmp_cmb.walk,f)) |
| 9599 | ✗ | return 8; | |
| 9600 | |||
| 9601 |
1/2✓ Branch 0 taken 82498 times.
✗ Branch 1 not taken.
|
82498 | if(!p_putc(tmp_cmb.type,f)) |
| 9602 | ✗ | return 9; | |
| 9603 | |||
| 9604 |
1/2✓ Branch 0 taken 82498 times.
✗ Branch 1 not taken.
|
82498 | if(!p_putc(tmp_cmb.flag,f)) |
| 9605 | ✗ | return 15; | |
| 9606 | |||
| 9607 |
1/2✓ Branch 0 taken 82498 times.
✗ Branch 1 not taken.
|
82498 | if(!p_putc(tmp_cmb.csets,f)) |
| 9608 | ✗ | return 10; | |
| 9609 | 82498 | } | |
| 9610 |
2/2✓ Branch 0 taken 82492 times.
✓ Branch 1 taken 6 times.
|
82498 | if(combo_has_flags&CHAS_SCRIPT) |
| 9611 | { | ||
| 9612 | 6 | p_putcstr(tmp_cmb.label, f); | |
| 9613 | |||
| 9614 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if(!p_iputw(tmp_cmb.script,f)) |
| 9615 | ✗ | return 26; | |
| 9616 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
|
54 | for ( int32_t q = 0; q < 8; q++ ) |
| 9617 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
|
48 | if(!p_iputl(tmp_cmb.initd[q],f)) |
| 9618 | ✗ | return 27; | |
| 9619 | 6 | } | |
| 9620 |
2/2✓ Branch 0 taken 54324 times.
✓ Branch 1 taken 28174 times.
|
82498 | if(combo_has_flags&CHAS_ANIM) |
| 9621 | { | ||
| 9622 |
1/2✓ Branch 0 taken 28174 times.
✗ Branch 1 not taken.
|
28174 | if(!p_putc(tmp_cmb.frames,f)) |
| 9623 | ✗ | return 11; | |
| 9624 | |||
| 9625 |
1/2✓ Branch 0 taken 28174 times.
✗ Branch 1 not taken.
|
28174 | if(!p_putc(tmp_cmb.speed,f)) |
| 9626 | ✗ | return 12; | |
| 9627 | |||
| 9628 |
1/2✓ Branch 0 taken 28174 times.
✗ Branch 1 not taken.
|
28174 | if(!p_iputw(tmp_cmb.nextcombo,f)) |
| 9629 | ✗ | return 13; | |
| 9630 | |||
| 9631 |
1/2✓ Branch 0 taken 28174 times.
✗ Branch 1 not taken.
|
28174 | if(!p_putc(tmp_cmb.nextcset,f)) |
| 9632 | ✗ | return 14; | |
| 9633 | |||
| 9634 |
1/2✓ Branch 0 taken 28174 times.
✗ Branch 1 not taken.
|
28174 | if(!p_putc(tmp_cmb.skipanim,f)) |
| 9635 | ✗ | return 16; | |
| 9636 | |||
| 9637 |
1/2✓ Branch 0 taken 28174 times.
✗ Branch 1 not taken.
|
28174 | if(!p_putc(tmp_cmb.skipanimy,f)) |
| 9638 | ✗ | return 18; | |
| 9639 | |||
| 9640 |
1/2✓ Branch 0 taken 28174 times.
✗ Branch 1 not taken.
|
28174 | if(!p_putc(tmp_cmb.animflags,f)) |
| 9641 | ✗ | return 19; | |
| 9642 | 28174 | } | |
| 9643 |
2/2✓ Branch 0 taken 79316 times.
✓ Branch 1 taken 3182 times.
|
82498 | if(combo_has_flags&CHAS_ATTRIB) |
| 9644 | { | ||
| 9645 |
2/2✓ Branch 0 taken 12728 times.
✓ Branch 1 taken 3182 times.
|
15910 | for ( int32_t q = 0; q < 4; q++ ) |
| 9646 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12728 times.
|
12728 | if(!p_iputl(tmp_cmb.attributes[q],f)) |
| 9647 | ✗ | return 20; | |
| 9648 |
2/2✓ Branch 0 taken 25456 times.
✓ Branch 1 taken 3182 times.
|
28638 | for ( int32_t q = 0; q < 8; q++ ) |
| 9649 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 25456 times.
|
25456 | if(!p_putc(tmp_cmb.attribytes[q],f)) |
| 9650 | ✗ | return 25; | |
| 9651 |
2/2✓ Branch 0 taken 25456 times.
✓ Branch 1 taken 3182 times.
|
28638 | for ( int32_t q = 0; q < 8; q++ ) //I also added attrishorts -Dimi |
| 9652 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 25456 times.
|
25456 | if(!p_iputw(tmp_cmb.attrishorts[q],f)) |
| 9653 | ✗ | return 32; | |
| 9654 | 3182 | } | |
| 9655 |
2/2✓ Branch 0 taken 82208 times.
✓ Branch 1 taken 290 times.
|
82498 | if(combo_has_flags&CHAS_FLAG) |
| 9656 | { | ||
| 9657 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
|
290 | if(!p_iputl(tmp_cmb.usrflags,f)) |
| 9658 | ✗ | return 21; | |
| 9659 |
1/2✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
|
290 | if(!p_iputw(tmp_cmb.genflags,f)) |
| 9660 | ✗ | return 33; | |
| 9661 | 290 | } | |
| 9662 |
2/2✓ Branch 0 taken 82038 times.
✓ Branch 1 taken 460 times.
|
82498 | if(combo_has_flags&CHAS_TRIG) |
| 9663 | { | ||
| 9664 |
2/2✓ Branch 0 taken 2760 times.
✓ Branch 1 taken 460 times.
|
3220 | for ( int32_t q = 0; q < 6; q++ ) |
| 9665 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2760 times.
|
2760 | if(!p_iputl(tmp_cmb.triggerflags[q],f)) |
| 9666 | ✗ | return 22; | |
| 9667 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputl(tmp_cmb.triggerlevel,f)) |
| 9668 | ✗ | return 23; | |
| 9669 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.triggerbtn,f)) |
| 9670 | ✗ | return 34; | |
| 9671 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.triggeritem,f)) |
| 9672 | ✗ | return 35; | |
| 9673 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trigtimer,f)) |
| 9674 | ✗ | return 36; | |
| 9675 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trigsfx,f)) |
| 9676 | ✗ | return 37; | |
| 9677 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputl(tmp_cmb.trigchange,f)) |
| 9678 | ✗ | return 38; | |
| 9679 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
|
460 | if(!p_iputw(tmp_cmb.trigprox,f)) |
| 9680 | ✗ | return 39; | |
| 9681 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trigctr,f)) |
| 9682 | ✗ | return 40; | |
| 9683 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputl(tmp_cmb.trigctramnt,f)) |
| 9684 | ✗ | return 41; | |
| 9685 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.triglbeam,f)) |
| 9686 | ✗ | return 42; | |
| 9687 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trigcschange,f)) |
| 9688 | ✗ | return 43; | |
| 9689 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.spawnitem,f)) |
| 9690 | ✗ | return 44; | |
| 9691 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.spawnenemy,f)) |
| 9692 | ✗ | return 45; | |
| 9693 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.exstate,f)) |
| 9694 | ✗ | return 46; | |
| 9695 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputl(tmp_cmb.spawnip,f)) |
| 9696 | ✗ | return 47; | |
| 9697 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trigcopycat,f)) |
| 9698 | ✗ | return 48; | |
| 9699 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trigcooldown,f)) |
| 9700 | ✗ | return 49; | |
| 9701 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.prompt_cid,f)) |
| 9702 | ✗ | return 50; | |
| 9703 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.prompt_cs,f)) |
| 9704 | ✗ | return 51; | |
| 9705 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.prompt_x,f)) |
| 9706 | ✗ | return 52; | |
| 9707 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.prompt_y,f)) |
| 9708 | ✗ | return 53; | |
| 9709 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trig_lstate,f)) |
| 9710 | ✗ | return 69; | |
| 9711 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trig_gstate,f)) |
| 9712 | ✗ | return 70; | |
| 9713 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputl(tmp_cmb.trig_statetime,f)) |
| 9714 | ✗ | return 71; | |
| 9715 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.trig_genscr,f)) |
| 9716 | ✗ | return 72; | |
| 9717 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trig_group,f)) |
| 9718 | ✗ | return 76; | |
| 9719 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.trig_group_val,f)) |
| 9720 | ✗ | return 77; | |
| 9721 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.exdoor_dir,f)) |
| 9722 | ✗ | return 89; | |
| 9723 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.exdoor_ind,f)) |
| 9724 | ✗ | return 90; | |
| 9725 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trig_levelitems,f)) |
| 9726 | ✗ | return 91; | |
| 9727 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.trigdmlevel,f)) |
| 9728 | ✗ | return 92; | |
| 9729 |
2/2✓ Branch 0 taken 1380 times.
✓ Branch 1 taken 460 times.
|
1840 | for(int q = 0; q < 3; ++q) |
| 9730 |
1/2✓ Branch 0 taken 1380 times.
✗ Branch 1 not taken.
|
1380 | if(!p_iputw(tmp_cmb.trigtint[q],f)) |
| 9731 | ✗ | return 93; | |
| 9732 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.triglvlpalette,f)) |
| 9733 | ✗ | return 94; | |
| 9734 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.trigbosspalette,f)) |
| 9735 | ✗ | return 95; | |
| 9736 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.trigquaketime,f)) |
| 9737 | ✗ | return 96; | |
| 9738 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.trigwavytime,f)) |
| 9739 | ✗ | return 97; | |
| 9740 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.trig_swjinxtime,f)) |
| 9741 | ✗ | return 98; | |
| 9742 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.trig_itmjinxtime,f)) |
| 9743 | ✗ | return 99; | |
| 9744 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.trig_stuntime,f)) |
| 9745 | ✗ | return 100; | |
| 9746 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_iputw(tmp_cmb.trig_bunnytime,f)) |
| 9747 | ✗ | return 101; | |
| 9748 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if(!p_putc(tmp_cmb.trig_pushtime,f)) |
| 9749 | ✗ | return 102; | |
| 9750 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if (!p_iputw(tmp_cmb.trig_shieldjinxtime, f)) |
| 9751 | ✗ | return 103; | |
| 9752 | 460 | } | |
| 9753 |
2/2✓ Branch 0 taken 82488 times.
✓ Branch 1 taken 10 times.
|
82498 | if(combo_has_flags&CHAS_LIFT) |
| 9754 | { | ||
| 9755 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_iputw(tmp_cmb.liftcmb,f)) |
| 9756 | ✗ | return 54; | |
| 9757 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.liftcs,f)) |
| 9758 | ✗ | return 55; | |
| 9759 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_iputw(tmp_cmb.liftundercmb,f)) |
| 9760 | ✗ | return 56; | |
| 9761 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.liftundercs,f)) |
| 9762 | ✗ | return 57; | |
| 9763 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.liftdmg,f)) |
| 9764 | ✗ | return 58; | |
| 9765 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.liftlvl,f)) |
| 9766 | ✗ | return 59; | |
| 9767 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.liftitm,f)) |
| 9768 | ✗ | return 60; | |
| 9769 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.liftflags,f)) |
| 9770 | ✗ | return 61; | |
| 9771 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.liftgfx,f)) |
| 9772 | ✗ | return 62; | |
| 9773 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.liftsprite,f)) |
| 9774 | ✗ | return 63; | |
| 9775 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.liftsfx,f)) |
| 9776 | ✗ | return 64; | |
| 9777 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_iputw(tmp_cmb.liftbreaksprite,f)) |
| 9778 | ✗ | return 65; | |
| 9779 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.liftbreaksfx,f)) |
| 9780 | ✗ | return 66; | |
| 9781 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.lifthei,f)) |
| 9782 | ✗ | return 67; | |
| 9783 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.lifttime,f)) |
| 9784 | ✗ | return 68; | |
| 9785 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_putc(tmp_cmb.lift_parent_item,f)) |
| 9786 | ✗ | return 78; | |
| 9787 | 10 | } | |
| 9788 |
2/2✓ Branch 0 taken 80298 times.
✓ Branch 1 taken 2200 times.
|
82498 | if(combo_has_flags&CHAS_GENERAL) |
| 9789 | { | ||
| 9790 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.speed_mult,f)) |
| 9791 | ✗ | return 73; | |
| 9792 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.speed_div,f)) |
| 9793 | ✗ | return 74; | |
| 9794 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_iputzf(tmp_cmb.speed_add,f)) |
| 9795 | ✗ | return 75; | |
| 9796 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.sfx_appear,f)) |
| 9797 | ✗ | return 79; | |
| 9798 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2200 times.
|
2200 | if(!p_putc(tmp_cmb.sfx_disappear,f)) |
| 9799 | ✗ | return 80; | |
| 9800 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.sfx_loop,f)) |
| 9801 | ✗ | return 81; | |
| 9802 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.sfx_walking,f)) |
| 9803 | ✗ | return 82; | |
| 9804 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.sfx_standing,f)) |
| 9805 | ✗ | return 83; | |
| 9806 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.spr_appear,f)) |
| 9807 | ✗ | return 84; | |
| 9808 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.spr_disappear,f)) |
| 9809 | ✗ | return 85; | |
| 9810 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.spr_walking,f)) |
| 9811 | ✗ | return 86; | |
| 9812 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.spr_standing,f)) |
| 9813 | ✗ | return 87; | |
| 9814 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.sfx_tap,f)) |
| 9815 | ✗ | return 88; | |
| 9816 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.sfx_landing,f)) |
| 9817 | ✗ | return 89; | |
| 9818 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.spr_falling,f)) |
| 9819 | ✗ | return 90; | |
| 9820 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.spr_drowning,f)) |
| 9821 | ✗ | return 91; | |
| 9822 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.spr_lava_drowning,f)) |
| 9823 | ✗ | return 92; | |
| 9824 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.sfx_falling,f)) |
| 9825 | ✗ | return 93; | |
| 9826 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2200 times.
|
2200 | if(!p_putc(tmp_cmb.sfx_drowning,f)) |
| 9827 | ✗ | return 94; | |
| 9828 |
1/2✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
|
2200 | if(!p_putc(tmp_cmb.sfx_lava_drowning,f)) |
| 9829 | ✗ | return 95; | |
| 9830 | 2200 | } | |
| 9831 | 82498 | return 0; | |
| 9832 | 393060 | } | |
| 9833 | |||
| 9834 | 9 | int32_t writecombos(PACKFILE *f, word version, word build, word start_combo, word max_combos) | |
| 9835 | { | ||
| 9836 | //these are here to bypass compiler warnings about unused arguments | ||
| 9837 | 9 | version=version; | |
| 9838 | 9 | build=build; | |
| 9839 | |||
| 9840 | word combos_used; | ||
| 9841 | 9 | dword section_id=ID_COMBOS; | |
| 9842 | 9 | dword section_version=V_COMBOS; | |
| 9843 | // dword section_size=0; | ||
| 9844 | 9 | combos_used = count_combos()-start_combo; | |
| 9845 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | combos_used = zc_min(combos_used, max_combos); |
| 9846 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | combos_used = zc_min(combos_used, MAXCOMBOS); |
| 9847 | 9 | dword section_size = 0; | |
| 9848 | |||
| 9849 | //section id | ||
| 9850 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 9851 | { | ||
| 9852 | ✗ | new_return(1); | |
| 9853 | } | ||
| 9854 | |||
| 9855 | //section version info | ||
| 9856 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 9857 | { | ||
| 9858 | ✗ | new_return(2); | |
| 9859 | } | ||
| 9860 | |||
| 9861 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 9862 | { | ||
| 9863 | ✗ | new_return(3); | |
| 9864 | } | ||
| 9865 | |||
| 9866 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 9867 | { | ||
| 9868 | 18 | fake_pack_writing=(writecycle==0); | |
| 9869 | |||
| 9870 | //section size | ||
| 9871 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 9872 | { | ||
| 9873 | ✗ | new_return(4); | |
| 9874 | } | ||
| 9875 | |||
| 9876 | 18 | writesize=0; | |
| 9877 | |||
| 9878 | //finally... section data | ||
| 9879 | 18 | combos_used=count_combos()-start_combo; | |
| 9880 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | combos_used=zc_min(combos_used, max_combos); |
| 9881 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | combos_used=zc_min(combos_used, MAXCOMBOS); |
| 9882 | |||
| 9883 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(combos_used,f)) |
| 9884 | { | ||
| 9885 | ✗ | new_return(5); | |
| 9886 | } | ||
| 9887 | |||
| 9888 | 18 | size_t end_combo = start_combo+combos_used; | |
| 9889 |
2/2✓ Branch 0 taken 258906 times.
✓ Branch 1 taken 18 times.
|
258924 | for(size_t q = start_combo; q < end_combo; ++q) |
| 9890 | { | ||
| 9891 | 258906 | auto ret = writecombo_loop(f, section_version, combobuf[q]); | |
| 9892 |
1/4✓ Branch 0 taken 258906 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
258906 | if(ret) new_return(ret); |
| 9893 | 258906 | } | |
| 9894 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 9895 | { | ||
| 9896 | 9 | section_size=writesize; | |
| 9897 | 9 | } | |
| 9898 | 18 | } | |
| 9899 | |||
| 9900 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 9901 | { | ||
| 9902 | char ebuf[80]; | ||
| 9903 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 9904 | ✗ | jwin_alert("Error: writecombos()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 9905 | ✗ | } | |
| 9906 | |||
| 9907 | 9 | new_return(0); | |
| 9908 | 9 | } | |
| 9909 | |||
| 9910 | 9 | int32_t writecomboaliases(PACKFILE *f, word version, word build) | |
| 9911 | { | ||
| 9912 | //these are here to bypass compiler warnings about unused arguments | ||
| 9913 | 9 | version=version; | |
| 9914 | 9 | build=build; | |
| 9915 | |||
| 9916 | 9 | dword section_id=ID_COMBOALIASES; | |
| 9917 | 9 | dword section_version=V_COMBOALIASES; | |
| 9918 | 9 | dword section_size=0; | |
| 9919 | |||
| 9920 | //section id | ||
| 9921 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 9922 | { | ||
| 9923 | ✗ | new_return(1); | |
| 9924 | } | ||
| 9925 | |||
| 9926 | //section version info | ||
| 9927 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 9928 | { | ||
| 9929 | ✗ | new_return(2); | |
| 9930 | } | ||
| 9931 | |||
| 9932 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 9933 | { | ||
| 9934 | ✗ | new_return(3); | |
| 9935 | } | ||
| 9936 | |||
| 9937 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 9938 | { | ||
| 9939 | 18 | fake_pack_writing=(writecycle==0); | |
| 9940 | |||
| 9941 | //section size | ||
| 9942 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 9943 | { | ||
| 9944 | ✗ | new_return(4); | |
| 9945 | } | ||
| 9946 | |||
| 9947 | 18 | writesize=0; | |
| 9948 | |||
| 9949 | //finally... section data | ||
| 9950 |
2/2✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18 times.
|
147474 | for(int32_t j=0; j<MAXCOMBOALIASES; j++) |
| 9951 | { | ||
| 9952 |
1/2✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
|
147456 | if(!p_iputw(combo_aliases[j].combo,f)) |
| 9953 | { | ||
| 9954 | ✗ | new_return(5); | |
| 9955 | } | ||
| 9956 | |||
| 9957 |
1/2✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
|
147456 | if(!p_putc(combo_aliases[j].cset,f)) |
| 9958 | { | ||
| 9959 | ✗ | new_return(6); | |
| 9960 | } | ||
| 9961 | |||
| 9962 | 147456 | int32_t count = ((combo_aliases[j].width+1)*(combo_aliases[j].height+1))*(comboa_lmasktotal(combo_aliases[j].layermask)+1); | |
| 9963 | |||
| 9964 |
1/2✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
|
147456 | if(!p_putc(combo_aliases[j].width,f)) |
| 9965 | { | ||
| 9966 | ✗ | new_return(7); | |
| 9967 | } | ||
| 9968 | |||
| 9969 |
1/2✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
|
147456 | if(!p_putc(combo_aliases[j].height,f)) |
| 9970 | { | ||
| 9971 | ✗ | new_return(8); | |
| 9972 | } | ||
| 9973 | |||
| 9974 |
1/2✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
|
147456 | if(!p_putc(combo_aliases[j].layermask,f)) |
| 9975 | { | ||
| 9976 | ✗ | new_return(9); | |
| 9977 | } | ||
| 9978 | |||
| 9979 |
2/2✓ Branch 0 taken 149596 times.
✓ Branch 1 taken 147456 times.
|
297052 | for(int32_t k=0; k<count; k++) |
| 9980 | { | ||
| 9981 |
1/2✓ Branch 0 taken 149596 times.
✗ Branch 1 not taken.
|
149596 | if(!p_iputw(combo_aliases[j].combos[k],f)) |
| 9982 | { | ||
| 9983 | ✗ | new_return(10); | |
| 9984 | } | ||
| 9985 | 149596 | } | |
| 9986 | |||
| 9987 |
2/2✓ Branch 0 taken 149596 times.
✓ Branch 1 taken 147456 times.
|
297052 | for(int32_t k=0; k<count; k++) |
| 9988 | { | ||
| 9989 |
1/2✓ Branch 0 taken 149596 times.
✗ Branch 1 not taken.
|
149596 | if(!p_putc(combo_aliases[j].csets[k],f)) |
| 9990 | { | ||
| 9991 | ✗ | new_return(11); | |
| 9992 | } | ||
| 9993 | 149596 | } | |
| 9994 | 147456 | } | |
| 9995 | |||
| 9996 | //Combo pools! | ||
| 9997 | int16_t num_cpools; | ||
| 9998 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 147452 times.
|
147468 | for(num_cpools = MAXCOMBOPOOLS-1; num_cpools >= 0; --num_cpools) |
| 9999 | { | ||
| 10000 |
2/2✓ Branch 0 taken 147450 times.
✓ Branch 1 taken 2 times.
|
147452 | if(combo_pools[num_cpools].valid()) //found a used pool |
| 10001 | { | ||
| 10002 | 2 | ++num_cpools; | |
| 10003 | 2 | break; | |
| 10004 | } | ||
| 10005 | 147450 | } | |
| 10006 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 16 times.
|
18 | if(num_cpools < 0) num_cpools = 0; |
| 10007 | |||
| 10008 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(num_cpools,f)) |
| 10009 | { | ||
| 10010 | ✗ | new_return(12); | |
| 10011 | } | ||
| 10012 | |||
| 10013 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
|
24 | for(auto cp = 0; cp < num_cpools; ++cp) |
| 10014 | { | ||
| 10015 | 6 | combo_pool const& pool = combo_pools[cp]; | |
| 10016 | 6 | int32_t num_combos = pool.combos.size(); | |
| 10017 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if(!p_iputl(num_combos,f)) |
| 10018 | { | ||
| 10019 | ✗ | new_return(13); | |
| 10020 | } | ||
| 10021 | |||
| 10022 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 6 times.
|
32 | for(auto q = 0; q < num_combos; ++q) |
| 10023 | { | ||
| 10024 | 26 | cpool_entry const& entry = pool.combos.at(q); | |
| 10025 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if(!p_iputl(entry.cid,f)) |
| 10026 | { | ||
| 10027 | ✗ | new_return(14); | |
| 10028 | } | ||
| 10029 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if(!p_putc(entry.cset,f)) |
| 10030 | { | ||
| 10031 | ✗ | new_return(15); | |
| 10032 | } | ||
| 10033 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if(!p_iputw(entry.quant,f)) |
| 10034 | { | ||
| 10035 | ✗ | new_return(16); | |
| 10036 | } | ||
| 10037 | 26 | } | |
| 10038 | 6 | } | |
| 10039 | |||
| 10040 | //Autocombos! | ||
| 10041 | int16_t num_cautos; | ||
| 10042 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 147456 times.
|
147474 | for (num_cautos = MAXAUTOCOMBOS - 1; num_cautos >= 0; --num_cautos) |
| 10043 | { | ||
| 10044 |
1/2✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
|
147456 | if (combo_autos[num_cautos].valid()) //found a used autocombo |
| 10045 | { | ||
| 10046 | ✗ | ++num_cautos; | |
| 10047 | ✗ | break; | |
| 10048 | } | ||
| 10049 | 147456 | } | |
| 10050 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | if (num_cautos < 0) num_cautos = 0; |
| 10051 | |||
| 10052 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (!p_iputw(num_cautos, f)) |
| 10053 | { | ||
| 10054 | ✗ | new_return(17); | |
| 10055 | } | ||
| 10056 | |||
| 10057 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | for (auto ca = 0; ca < num_cautos; ++ca) |
| 10058 | { | ||
| 10059 | ✗ | combo_auto const& cauto = combo_autos[ca]; | |
| 10060 | ✗ | if (!p_putc(cauto.getType(), f)) | |
| 10061 | { | ||
| 10062 | ✗ | new_return(18); | |
| 10063 | } | ||
| 10064 | ✗ | if (!p_iputl(cauto.getIconDisplay(), f)) | |
| 10065 | { | ||
| 10066 | ✗ | new_return(19); | |
| 10067 | } | ||
| 10068 | ✗ | if (!p_iputl(cauto.getEraseCombo(), f)) | |
| 10069 | { | ||
| 10070 | ✗ | new_return(20); | |
| 10071 | } | ||
| 10072 | ✗ | if (!p_putc(cauto.getFlags(), f)) | |
| 10073 | { | ||
| 10074 | ✗ | new_return(21); | |
| 10075 | } | ||
| 10076 | ✗ | if (!p_putc(cauto.getArg(), f)) | |
| 10077 | { | ||
| 10078 | ✗ | new_return(22); | |
| 10079 | } | ||
| 10080 | ✗ | int32_t num_combos = cauto.combos.size(); | |
| 10081 | ✗ | if (!p_iputl(num_combos, f)) | |
| 10082 | { | ||
| 10083 | ✗ | new_return(23); | |
| 10084 | } | ||
| 10085 | |||
| 10086 | ✗ | for (auto q = 0; q < num_combos; ++q) | |
| 10087 | { | ||
| 10088 | ✗ | autocombo_entry const& entry = cauto.combos.at(q); | |
| 10089 | ✗ | if (!p_putc(entry.ctype, f)) | |
| 10090 | { | ||
| 10091 | ✗ | new_return(24); | |
| 10092 | } | ||
| 10093 | ✗ | if (!p_iputl(entry.cid, f)) | |
| 10094 | { | ||
| 10095 | ✗ | new_return(25); | |
| 10096 | } | ||
| 10097 | ✗ | } | |
| 10098 | ✗ | } | |
| 10099 | |||
| 10100 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 10101 | { | ||
| 10102 | 9 | section_size=writesize; | |
| 10103 | 9 | } | |
| 10104 | 18 | } | |
| 10105 | |||
| 10106 | |||
| 10107 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 10108 | { | ||
| 10109 | char ebuf[80]; | ||
| 10110 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 10111 | ✗ | jwin_alert("Error: writecomboaliases()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 10112 | ✗ | } | |
| 10113 | |||
| 10114 | 9 | new_return(0); | |
| 10115 | } | ||
| 10116 | |||
| 10117 | 9 | int32_t writecolordata(PACKFILE *f, word version, word build, word start_cset, word max_csets) | |
| 10118 | { | ||
| 10119 | //these are here to bypass compiler warnings about unused arguments | ||
| 10120 | 9 | version=version; | |
| 10121 | 9 | build=build; | |
| 10122 | 9 | start_cset=start_cset; | |
| 10123 | 9 | max_csets=max_csets; | |
| 10124 | |||
| 10125 | 9 | dword section_id=ID_CSETS; | |
| 10126 | 9 | dword section_version=V_CSETS; | |
| 10127 | 9 | int32_t palcycles = count_palcycles(&QMisc); | |
| 10128 | // int32_t palcyccount = count_palcycles(&QMisc); | ||
| 10129 | 9 | dword section_size = 0; | |
| 10130 | |||
| 10131 | //section id | ||
| 10132 | |||
| 10133 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 10134 | { | ||
| 10135 | ✗ | new_return(1); | |
| 10136 | } | ||
| 10137 | |||
| 10138 | //section version info | ||
| 10139 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 10140 | { | ||
| 10141 | ✗ | new_return(2); | |
| 10142 | } | ||
| 10143 | |||
| 10144 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 10145 | { | ||
| 10146 | ✗ | new_return(3); | |
| 10147 | } | ||
| 10148 | |||
| 10149 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 10150 | { | ||
| 10151 | 18 | fake_pack_writing=(writecycle==0); | |
| 10152 | |||
| 10153 | //section size | ||
| 10154 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 10155 | { | ||
| 10156 | ✗ | new_return(4); | |
| 10157 | } | ||
| 10158 | |||
| 10159 | 18 | writesize=0; | |
| 10160 | |||
| 10161 | //finally... section data | ||
| 10162 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(colordata,psTOTAL255,f)) |
| 10163 | { | ||
| 10164 | ✗ | new_return(5); | |
| 10165 | } | ||
| 10166 | |||
| 10167 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(palnames,MAXLEVELS*PALNAMESIZE,f)) |
| 10168 | { | ||
| 10169 | ✗ | new_return(6); | |
| 10170 | } | ||
| 10171 | |||
| 10172 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(palcycles,f)) |
| 10173 | { | ||
| 10174 | ✗ | new_return(15); | |
| 10175 | } | ||
| 10176 | |||
| 10177 |
2/2✓ Branch 0 taken 550 times.
✓ Branch 1 taken 18 times.
|
568 | for(int32_t i=0; i<palcycles; i++) |
| 10178 | { | ||
| 10179 |
2/2✓ Branch 0 taken 1650 times.
✓ Branch 1 taken 550 times.
|
2200 | for(int32_t j=0; j<3; j++) |
| 10180 | { | ||
| 10181 |
1/2✓ Branch 0 taken 1650 times.
✗ Branch 1 not taken.
|
1650 | if(!p_putc(QMisc.cycles[i][j].first,f)) |
| 10182 | { | ||
| 10183 | ✗ | new_return(16); | |
| 10184 | } | ||
| 10185 | 1650 | } | |
| 10186 | |||
| 10187 |
2/2✓ Branch 0 taken 1650 times.
✓ Branch 1 taken 550 times.
|
2200 | for(int32_t j=0; j<3; j++) |
| 10188 | { | ||
| 10189 |
1/2✓ Branch 0 taken 1650 times.
✗ Branch 1 not taken.
|
1650 | if(!p_putc(QMisc.cycles[i][j].count,f)) |
| 10190 | { | ||
| 10191 | ✗ | new_return(17); | |
| 10192 | } | ||
| 10193 | 1650 | } | |
| 10194 | |||
| 10195 |
2/2✓ Branch 0 taken 1650 times.
✓ Branch 1 taken 550 times.
|
2200 | for(int32_t j=0; j<3; j++) |
| 10196 | { | ||
| 10197 |
1/2✓ Branch 0 taken 1650 times.
✗ Branch 1 not taken.
|
1650 | if(!p_putc(QMisc.cycles[i][j].speed,f)) |
| 10198 | { | ||
| 10199 | ✗ | new_return(18); | |
| 10200 | } | ||
| 10201 | 1650 | } | |
| 10202 | 550 | } | |
| 10203 | |||
| 10204 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 10205 | { | ||
| 10206 | 9 | section_size=writesize; | |
| 10207 | 9 | } | |
| 10208 | 18 | } | |
| 10209 | |||
| 10210 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 10211 | { | ||
| 10212 | char ebuf[80]; | ||
| 10213 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 10214 | ✗ | jwin_alert("Error: writecolordata()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 10215 | ✗ | } | |
| 10216 | |||
| 10217 | 9 | new_return(0); | |
| 10218 | } | ||
| 10219 | |||
| 10220 | 9 | int32_t writestrings(PACKFILE *f, word version, word build, word start_msgstr, word max_msgstrs) | |
| 10221 | { | ||
| 10222 | //these are here to bypass compiler warnings about unused arguments | ||
| 10223 | 9 | version=version; | |
| 10224 | 9 | build=build; | |
| 10225 | 9 | start_msgstr=start_msgstr; | |
| 10226 | 9 | max_msgstrs=max_msgstrs; | |
| 10227 | |||
| 10228 | 9 | dword section_id=ID_STRINGS; | |
| 10229 | 9 | dword section_version=V_STRINGS; | |
| 10230 | 9 | dword section_size = 0; | |
| 10231 | |||
| 10232 | //section id | ||
| 10233 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 10234 | { | ||
| 10235 | ✗ | new_return(1); | |
| 10236 | } | ||
| 10237 | |||
| 10238 | //section version info | ||
| 10239 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 10240 | { | ||
| 10241 | ✗ | new_return(2); | |
| 10242 | } | ||
| 10243 | |||
| 10244 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 10245 | { | ||
| 10246 | ✗ | new_return(3); | |
| 10247 | } | ||
| 10248 | |||
| 10249 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 10250 | { | ||
| 10251 | 18 | fake_pack_writing=(writecycle==0); | |
| 10252 | |||
| 10253 | //section size | ||
| 10254 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 10255 | { | ||
| 10256 | ✗ | new_return(4); | |
| 10257 | } | ||
| 10258 | |||
| 10259 | 18 | writesize=0; | |
| 10260 | |||
| 10261 | //finally... section data | ||
| 10262 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(msg_count,f)) |
| 10263 | { | ||
| 10264 | ✗ | return qe_invalid; | |
| 10265 | } | ||
| 10266 | |||
| 10267 |
2/2✓ Branch 0 taken 836 times.
✓ Branch 1 taken 18 times.
|
854 | for(int32_t i=0; i<msg_count; i++) |
| 10268 | { | ||
| 10269 | 836 | int32_t sz = MsgStrings[i].s.size(); | |
| 10270 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(sz > 8192) sz = 8192; |
| 10271 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_iputl(sz, f)) |
| 10272 | { | ||
| 10273 | ✗ | return qe_invalid; | |
| 10274 | } | ||
| 10275 | |||
| 10276 | 836 | char const* tmpstr = MsgStrings[i].s.c_str(); | |
| 10277 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 836 times.
|
836 | if (sz > 0) |
| 10278 | { | ||
| 10279 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if (!pfwrite((void*)tmpstr,sz, f)) |
| 10280 | { | ||
| 10281 | ✗ | return qe_invalid; | |
| 10282 | } | ||
| 10283 | 836 | } | |
| 10284 | |||
| 10285 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_iputw(MsgStrings[i].nextstring,f)) |
| 10286 | { | ||
| 10287 | ✗ | return qe_invalid; | |
| 10288 | } | ||
| 10289 | |||
| 10290 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_iputl(MsgStrings[i].tile,f)) |
| 10291 | { | ||
| 10292 | ✗ | return qe_invalid; | |
| 10293 | } | ||
| 10294 | |||
| 10295 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].cset,f)) |
| 10296 | { | ||
| 10297 | ✗ | return qe_invalid; | |
| 10298 | } | ||
| 10299 | |||
| 10300 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].trans?1:0,f)) |
| 10301 | { | ||
| 10302 | ✗ | return qe_invalid; | |
| 10303 | } | ||
| 10304 | |||
| 10305 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].font,f)) |
| 10306 | { | ||
| 10307 | ✗ | return qe_invalid; | |
| 10308 | } | ||
| 10309 | |||
| 10310 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_iputw(MsgStrings[i].x,f)) |
| 10311 | { | ||
| 10312 | ✗ | return qe_invalid; | |
| 10313 | } | ||
| 10314 | |||
| 10315 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_iputw(MsgStrings[i].y,f)) |
| 10316 | { | ||
| 10317 | ✗ | return qe_invalid; | |
| 10318 | } | ||
| 10319 | |||
| 10320 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_iputw(MsgStrings[i].w,f)) |
| 10321 | { | ||
| 10322 | ✗ | return qe_invalid; | |
| 10323 | } | ||
| 10324 | |||
| 10325 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_iputw(MsgStrings[i].h,f)) |
| 10326 | { | ||
| 10327 | ✗ | return qe_invalid; | |
| 10328 | } | ||
| 10329 | |||
| 10330 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].hspace,f)) |
| 10331 | { | ||
| 10332 | ✗ | return qe_invalid; | |
| 10333 | } | ||
| 10334 | |||
| 10335 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].vspace,f)) |
| 10336 | { | ||
| 10337 | ✗ | return qe_invalid; | |
| 10338 | } | ||
| 10339 | |||
| 10340 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].stringflags,f)) |
| 10341 | { | ||
| 10342 | ✗ | return qe_invalid; | |
| 10343 | } | ||
| 10344 | |||
| 10345 |
2/2✓ Branch 0 taken 3344 times.
✓ Branch 1 taken 836 times.
|
4180 | for(int32_t q = 0; q < 4; ++q) |
| 10346 | { | ||
| 10347 |
1/2✓ Branch 0 taken 3344 times.
✗ Branch 1 not taken.
|
3344 | if(!p_putc(MsgStrings[i].margins[q],f)) |
| 10348 | { | ||
| 10349 | ✗ | return qe_invalid; | |
| 10350 | } | ||
| 10351 | 3344 | } | |
| 10352 | |||
| 10353 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_iputl(MsgStrings[i].portrait_tile,f)) |
| 10354 | { | ||
| 10355 | ✗ | return qe_invalid; | |
| 10356 | } | ||
| 10357 | |||
| 10358 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].portrait_cset,f)) |
| 10359 | { | ||
| 10360 | ✗ | return qe_invalid; | |
| 10361 | } | ||
| 10362 | |||
| 10363 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].portrait_x,f)) |
| 10364 | { | ||
| 10365 | ✗ | return qe_invalid; | |
| 10366 | } | ||
| 10367 | |||
| 10368 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].portrait_y,f)) |
| 10369 | { | ||
| 10370 | ✗ | return qe_invalid; | |
| 10371 | } | ||
| 10372 | |||
| 10373 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].portrait_tw,f)) |
| 10374 | { | ||
| 10375 | ✗ | return qe_invalid; | |
| 10376 | } | ||
| 10377 | |||
| 10378 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].portrait_th,f)) |
| 10379 | { | ||
| 10380 | ✗ | return qe_invalid; | |
| 10381 | } | ||
| 10382 | |||
| 10383 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].shadow_type,f)) |
| 10384 | { | ||
| 10385 | ✗ | return qe_invalid; | |
| 10386 | } | ||
| 10387 | |||
| 10388 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].shadow_color,f)) |
| 10389 | { | ||
| 10390 | ✗ | return qe_invalid; | |
| 10391 | } | ||
| 10392 | |||
| 10393 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].drawlayer,f)) |
| 10394 | { | ||
| 10395 | ✗ | return qe_invalid; | |
| 10396 | } | ||
| 10397 | |||
| 10398 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_putc(MsgStrings[i].sfx,f)) |
| 10399 | { | ||
| 10400 | ✗ | return qe_invalid; | |
| 10401 | } | ||
| 10402 | |||
| 10403 |
1/2✓ Branch 0 taken 836 times.
✗ Branch 1 not taken.
|
836 | if(!p_iputw(MsgStrings[i].listpos,f)) |
| 10404 | { | ||
| 10405 | ✗ | return qe_invalid; | |
| 10406 | } | ||
| 10407 | 836 | } | |
| 10408 | |||
| 10409 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 10410 | { | ||
| 10411 | 9 | section_size=writesize; | |
| 10412 | 9 | } | |
| 10413 | 18 | } | |
| 10414 | |||
| 10415 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 10416 | { | ||
| 10417 | char ebuf[80]; | ||
| 10418 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 10419 | ✗ | jwin_alert("Error: writestrings()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 10420 | ✗ | } | |
| 10421 | |||
| 10422 | 9 | new_return(0); | |
| 10423 | 9 | } | |
| 10424 | |||
| 10425 | ✗ | int32_t writestrings_text(PACKFILE *f) | |
| 10426 | { | ||
| 10427 | ✗ | std::map<int32_t, int32_t> msglistcache; | |
| 10428 | |||
| 10429 | ✗ | for(int32_t index = 1; index<msg_count; index++) | |
| 10430 | { | ||
| 10431 | ✗ | for(int32_t i=1; i<msg_count; i++) | |
| 10432 | { | ||
| 10433 | ✗ | if(MsgStrings[i].listpos==index) | |
| 10434 | { | ||
| 10435 | ✗ | msglistcache[index-1]=i; | |
| 10436 | ✗ | break; | |
| 10437 | } | ||
| 10438 | ✗ | } | |
| 10439 | ✗ | } | |
| 10440 | |||
| 10441 | ✗ | for(int32_t writecycle=0; writecycle<2; ++writecycle) | |
| 10442 | { | ||
| 10443 | ✗ | fake_pack_writing=(writecycle==0); | |
| 10444 | char ebuf[32]; | ||
| 10445 | |||
| 10446 | ✗ | sprintf(ebuf,"Total strings: %d\n", msg_count-1); | |
| 10447 | |||
| 10448 | ✗ | if(!pfwrite(&ebuf,(int32_t)strlen(ebuf),f)) | |
| 10449 | { | ||
| 10450 | ✗ | return qe_invalid; | |
| 10451 | } | ||
| 10452 | |||
| 10453 | ✗ | for(int32_t i=1; i<msg_count; i++) | |
| 10454 | { | ||
| 10455 | ✗ | int32_t str = msglistcache[i-1]; | |
| 10456 | |||
| 10457 | ✗ | if(!str) | |
| 10458 | ✗ | continue; | |
| 10459 | |||
| 10460 | ✗ | if(MsgStrings[str].nextstring != 0) | |
| 10461 | ✗ | sprintf(ebuf,"\n\n___%d(->%d)___\n", str,MsgStrings[str].nextstring); | |
| 10462 | else | ||
| 10463 | ✗ | sprintf(ebuf,"\n\n___%d___\n", str); | |
| 10464 | |||
| 10465 | ✗ | if(!pfwrite(&ebuf,(int32_t)strlen(ebuf),f)) | |
| 10466 | { | ||
| 10467 | ✗ | return qe_invalid; | |
| 10468 | } | ||
| 10469 | |||
| 10470 | ✗ | std::string text = MsgStrings[str].serialize(); | |
| 10471 | ✗ | if (!pfwrite(text.c_str(), text.size(), f)) | |
| 10472 | { | ||
| 10473 | ✗ | return qe_invalid; | |
| 10474 | } | ||
| 10475 | ✗ | } | |
| 10476 | ✗ | } | |
| 10477 | |||
| 10478 | ✗ | new_return(0); | |
| 10479 | ✗ | } | |
| 10480 | |||
| 10481 | 1 | int32_t writestrings_tsv(PACKFILE *f) | |
| 10482 | { | ||
| 10483 | 1 | std::stringstream ss; | |
| 10484 | |||
| 10485 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | std::vector<std::pair<std::string, std::function<std::string(const MsgStr&)>>> fields = { |
| 10486 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "message", [&](auto& msg){ return msg.serialize(); }}, |
| 10487 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "next", [](auto& msg){ return std::to_string(msg.nextstring); } }, |
| 10488 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "tile", [](auto& msg){ return std::to_string(msg.tile); } }, |
| 10489 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "cset", [](auto& msg){ return std::to_string(msg.cset); } }, |
| 10490 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "trans", [](auto& msg){ return std::to_string(msg.trans); } }, |
| 10491 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "font", [](auto& msg){ return std::to_string(msg.font); } }, |
| 10492 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "x", [](auto& msg){ return std::to_string(msg.x); } }, |
| 10493 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "y", [](auto& msg){ return std::to_string(msg.y); } }, |
| 10494 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "w", [](auto& msg){ return std::to_string(msg.w); } }, |
| 10495 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "h", [](auto& msg){ return std::to_string(msg.h); } }, |
| 10496 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "sfx", [](auto& msg){ return std::to_string(msg.sfx); } }, |
| 10497 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "pos", [](auto& msg){ return std::to_string(msg.listpos); } }, |
| 10498 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "vspace", [](auto& msg){ return std::to_string(msg.vspace); } }, |
| 10499 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "hspace", [](auto& msg){ return std::to_string(msg.hspace); } }, |
| 10500 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "flags", [](auto& msg){ return std::to_string(msg.stringflags); } }, |
| 10501 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "margin", [](auto& msg){ return fmt::format("{} {} {} {}", msg.margins[0], msg.margins[3], msg.margins[1], msg.margins[2]); } }, |
| 10502 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "portrait_tile", [](auto& msg){ return std::to_string(msg.portrait_tile); } }, |
| 10503 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "portrait_cset", [](auto& msg){ return std::to_string(msg.portrait_cset); } }, |
| 10504 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "portrait_x", [](auto& msg){ return std::to_string(msg.portrait_x); } }, |
| 10505 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "portrait_y", [](auto& msg){ return std::to_string(msg.portrait_y); } }, |
| 10506 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "portrait_tw", [](auto& msg){ return std::to_string(msg.portrait_tw); } }, |
| 10507 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "portrait_th", [](auto& msg){ return std::to_string(msg.portrait_th); } }, |
| 10508 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "shadow_type", [](auto& msg){ return std::to_string(msg.shadow_type); } }, |
| 10509 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "shadow_color", [](auto& msg){ return std::to_string(msg.shadow_color); } }, |
| 10510 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
36 | { "drawlayer", [](auto& msg){ return std::to_string(msg.drawlayer); } }, |
| 10511 | }; | ||
| 10512 | |||
| 10513 |
1/2✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
|
25 | for (auto& [name, fn] : fields) |
| 10514 | { | ||
| 10515 |
2/4✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
|
50 | ss << name; |
| 10516 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
|
25 | if (name == fields.back().first) |
| 10517 | 1 | break; | |
| 10518 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | ss << '\t'; |
| 10519 | } | ||
| 10520 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | ss << '\n'; |
| 10521 | |||
| 10522 | // First entry is a fake string, to help frame the lines. Should be helpful if manually editing these in a text editor or spreadsheet. | ||
| 10523 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | ss << "|IT'S DANGEROUS TO GO || ALONE! TAKE THIS. ||LOREM IPSUM LOREM IPSU|\n"; |
| 10524 | |||
| 10525 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
|
36 | for(int32_t i=1; i<msg_count; i++) |
| 10526 | { | ||
| 10527 | 35 | auto& msg = MsgStrings[i]; | |
| 10528 |
1/2✓ Branch 0 taken 875 times.
✗ Branch 1 not taken.
|
1750 | for (auto& [name, fn] : fields) |
| 10529 | { | ||
| 10530 |
1/2✓ Branch 0 taken 875 times.
✗ Branch 1 not taken.
|
875 | std::string text = fn(msg); |
| 10531 |
1/2✓ Branch 0 taken 875 times.
✗ Branch 1 not taken.
|
875 | ss << text; |
| 10532 |
2/2✓ Branch 0 taken 840 times.
✓ Branch 1 taken 35 times.
|
875 | if (name == fields.back().first) |
| 10533 | 35 | break; | |
| 10534 |
1/2✓ Branch 0 taken 840 times.
✗ Branch 1 not taken.
|
840 | ss << '\t'; |
| 10535 |
2/3✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 840 times.
|
875 | } |
| 10536 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | ss << '\n'; |
| 10537 | 35 | } | |
| 10538 | |||
| 10539 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | std::string text = ss.str(); |
| 10540 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | if (!pack_fwrite(text.c_str(), text.size(), f)) |
| 10541 | { | ||
| 10542 | ✗ | return qe_invalid; | |
| 10543 | } | ||
| 10544 | |||
| 10545 | 1 | new_return(0); | |
| 10546 | 1 | } | |
| 10547 | |||
| 10548 | std::string parse_to_legacy_msg_str_encoding(std::string const& s); | ||
| 10549 | |||
| 10550 | ✗ | void parse_strings_tsv(std::string tsv) | |
| 10551 | { | ||
| 10552 | ✗ | std::map<std::string, std::function<void(MsgStr&, const std::string&)>> fields = { | |
| 10553 | ✗ | { "message", [](auto& msg, auto& text){ msg.setFromLegacyEncoding(parse_to_legacy_msg_str_encoding(text)); } }, | |
| 10554 | ✗ | { "next", [](auto& msg, auto& text){ msg.nextstring = std::stoi(text); } }, | |
| 10555 | ✗ | { "tile", [](auto& msg, auto& text){ msg.tile = std::stoi(text); } }, | |
| 10556 | ✗ | { "cset", [](auto& msg, auto& text){ msg.cset = std::stoi(text); } }, | |
| 10557 | ✗ | { "trans", [](auto& msg, auto& text){ msg.trans = std::stoi(text); } }, | |
| 10558 | ✗ | { "font", [](auto& msg, auto& text){ msg.font = std::stoi(text); } }, | |
| 10559 | ✗ | { "x", [](auto& msg, auto& text){ msg.x = std::stoi(text); } }, | |
| 10560 | ✗ | { "y", [](auto& msg, auto& text){ msg.y = std::stoi(text); } }, | |
| 10561 | ✗ | { "w", [](auto& msg, auto& text){ msg.w = std::stoi(text); } }, | |
| 10562 | ✗ | { "h", [](auto& msg, auto& text){ msg.h = std::stoi(text); } }, | |
| 10563 | ✗ | { "sfx", [](auto& msg, auto& text){ msg.sfx = std::stoi(text); } }, | |
| 10564 | ✗ | { "pos", [](auto& msg, auto& text){ msg.listpos = std::stoi(text); } }, | |
| 10565 | ✗ | { "vspace", [](auto& msg, auto& text){ msg.vspace = std::stoi(text); } }, | |
| 10566 | ✗ | { "hspace", [](auto& msg, auto& text){ msg.hspace = std::stoi(text); } }, | |
| 10567 | ✗ | { "flags", [](auto& msg, auto& text){ msg.stringflags = std::stoi(text); } }, | |
| 10568 | ✗ | { "margin", [&](auto& msg, auto& text){ | |
| 10569 | ✗ | std::vector<std::string> strs; | |
| 10570 | ✗ | util::split(text, strs, ' '); | |
| 10571 | ✗ | if (strs.size() != 4) | |
| 10572 | ✗ | throw std::runtime_error("margin field must have 4 components"); | |
| 10573 | ✗ | msg.margins[0] = std::stoi(strs[0]); | |
| 10574 | ✗ | msg.margins[1] = std::stoi(strs[1]); | |
| 10575 | ✗ | msg.margins[2] = std::stoi(strs[2]); | |
| 10576 | ✗ | msg.margins[3] = std::stoi(strs[3]); | |
| 10577 | ✗ | } }, | |
| 10578 | ✗ | { "portrait_tile", [](auto& msg, auto& text){ msg.portrait_tile = std::stoi(text); } }, | |
| 10579 | ✗ | { "portrait_cset", [](auto& msg, auto& text){ msg.portrait_cset = std::stoi(text); } }, | |
| 10580 | ✗ | { "portrait_x", [](auto& msg, auto& text){ msg.portrait_x = std::stoi(text); } }, | |
| 10581 | ✗ | { "portrait_y", [](auto& msg, auto& text){ msg.portrait_y = std::stoi(text); } }, | |
| 10582 | ✗ | { "portrait_tw", [](auto& msg, auto& text){ msg.portrait_tw = std::stoi(text); } }, | |
| 10583 | ✗ | { "portrait_th", [](auto& msg, auto& text){ msg.portrait_th = std::stoi(text); } }, | |
| 10584 | ✗ | { "shadow_type", [](auto& msg, auto& text){ msg.shadow_type = std::stoi(text); } }, | |
| 10585 | ✗ | { "shadow_color", [](auto& msg, auto& text){ msg.shadow_color = std::stoi(text); } }, | |
| 10586 | ✗ | { "drawlayer", [](auto& msg, auto& text){ msg.drawlayer = std::stoi(text); } }, | |
| 10587 | }; | ||
| 10588 | |||
| 10589 | ✗ | std::vector<std::string> rows; | |
| 10590 | ✗ | util::split(tsv, rows, '\n'); | |
| 10591 | ✗ | if (rows.size()) | |
| 10592 | { | ||
| 10593 | ✗ | std::string last = rows.back(); | |
| 10594 | ✗ | util::trimstr(last); | |
| 10595 | ✗ | if (last.empty()) | |
| 10596 | ✗ | rows.pop_back(); | |
| 10597 | ✗ | } | |
| 10598 | ✗ | if (rows.size() <= 1) | |
| 10599 | ✗ | throw std::runtime_error("missing header row"); | |
| 10600 | |||
| 10601 | ✗ | std::vector<std::string> columns; | |
| 10602 | ✗ | util::split(rows[0], columns, '\t'); | |
| 10603 | ✗ | for (auto name : columns) | |
| 10604 | { | ||
| 10605 | ✗ | if (!fields.contains(name)) | |
| 10606 | ✗ | throw std::runtime_error(fmt::format("invalid field: {}", name)); | |
| 10607 | ✗ | } | |
| 10608 | |||
| 10609 | ✗ | int start_index = 1; | |
| 10610 | ✗ | if (rows[start_index].find("||LOREM IPSUM") != std::string::npos) | |
| 10611 | ✗ | start_index += 1; | |
| 10612 | |||
| 10613 | ✗ | int num_strings = rows.size() - start_index + 1; | |
| 10614 | ✗ | if (num_strings > MAXMSGS-1) | |
| 10615 | ✗ | throw std::runtime_error(fmt::format("too many strings, max is {}", MAXMSGS-1)); | |
| 10616 | |||
| 10617 | ✗ | std::vector<MsgStr> msgs; | |
| 10618 | ✗ | msgs.reserve(num_strings); | |
| 10619 | ✗ | for (int i = start_index; i < rows.size(); i++) | |
| 10620 | { | ||
| 10621 | ✗ | std::vector<std::string> strs; | |
| 10622 | ✗ | util::split(rows[i], strs, '\t'); | |
| 10623 | ✗ | if (strs.size() != columns.size()) | |
| 10624 | ✗ | throw std::runtime_error(fmt::format("row {} has {} fields, expected {}", i, strs.size(), columns.size())); | |
| 10625 | |||
| 10626 | ✗ | int j = 0; | |
| 10627 | ✗ | auto& msg = msgs.emplace_back(); | |
| 10628 | ✗ | for (auto& name : columns) | |
| 10629 | { | ||
| 10630 | ✗ | auto& fn = fields[name]; | |
| 10631 | try | ||
| 10632 | { | ||
| 10633 | ✗ | fn(msg, strs[j++]); | |
| 10634 | ✗ | } | |
| 10635 | catch (std::exception& ex) | ||
| 10636 | { | ||
| 10637 | ✗ | throw std::runtime_error(fmt::format("error parsing row {} field {}: {}", i, name, ex.what())); | |
| 10638 | ✗ | } | |
| 10639 | } | ||
| 10640 | ✗ | } | |
| 10641 | |||
| 10642 | ✗ | init_msgstrings(0, msgs.size()); | |
| 10643 | ✗ | for (int i = 0; i < msgs.size(); i++) | |
| 10644 | ✗ | MsgStrings[i + 1] = msgs[i]; | |
| 10645 | ✗ | msg_count = msgs.size(); | |
| 10646 | ✗ | msglistcache.clear(); | |
| 10647 | ✗ | } | |
| 10648 | |||
| 10649 | bool isblanktile(tiledata *buf, int32_t i); | ||
| 10650 | 9 | int32_t writetiles(PACKFILE *f, word version, word build, int32_t start_tile, int32_t max_tiles) | |
| 10651 | { | ||
| 10652 | //these are here to bypass compiler warnings about unused arguments | ||
| 10653 | 9 | version=version; | |
| 10654 | 9 | build=build; | |
| 10655 | |||
| 10656 | int32_t tiles_used; | ||
| 10657 | 9 | dword section_id=ID_TILES; | |
| 10658 | 9 | dword section_version=V_TILES; | |
| 10659 | 9 | al_trace("Counting tiles used\n"); | |
| 10660 | 9 | tiles_used = count_tiles(newtilebuf)-start_tile; | |
| 10661 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | tiles_used = zc_min(tiles_used, max_tiles); |
| 10662 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | tiles_used = zc_min(tiles_used, NEWMAXTILES); |
| 10663 | 9 | al_trace("writetiles counted %dtiles used.\n",tiles_used); | |
| 10664 | 9 | dword section_size = 0; | |
| 10665 | |||
| 10666 | //section id | ||
| 10667 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 10668 | { | ||
| 10669 | ✗ | new_return(1); | |
| 10670 | } | ||
| 10671 | |||
| 10672 | //section version info | ||
| 10673 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 10674 | { | ||
| 10675 | ✗ | new_return(2); | |
| 10676 | } | ||
| 10677 | |||
| 10678 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 10679 | { | ||
| 10680 | ✗ | new_return(3); | |
| 10681 | } | ||
| 10682 | |||
| 10683 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 10684 | { | ||
| 10685 | 18 | fake_pack_writing=(writecycle==0); | |
| 10686 | |||
| 10687 | //section size | ||
| 10688 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 10689 | { | ||
| 10690 | ✗ | new_return(4); | |
| 10691 | } | ||
| 10692 | |||
| 10693 | 18 | writesize=0; | |
| 10694 | |||
| 10695 | //finally... section data | ||
| 10696 | 18 | tiles_used=count_tiles(newtilebuf)-start_tile; | |
| 10697 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | tiles_used=zc_min(tiles_used, max_tiles); |
| 10698 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | tiles_used=zc_min(tiles_used, NEWMAXTILES); |
| 10699 | |||
| 10700 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(tiles_used,f)) |
| 10701 | { | ||
| 10702 | ✗ | new_return(5); | |
| 10703 | } | ||
| 10704 | |||
| 10705 |
2/2✓ Branch 0 taken 696384 times.
✓ Branch 1 taken 18 times.
|
696402 | for(int32_t i=0; i<tiles_used; ++i) |
| 10706 | { | ||
| 10707 |
2/2✓ Branch 0 taken 365770 times.
✓ Branch 1 taken 330614 times.
|
696384 | if(isblanktile(newtilebuf, start_tile+i)) |
| 10708 | { | ||
| 10709 |
1/2✓ Branch 0 taken 365770 times.
✗ Branch 1 not taken.
|
365770 | if(!p_putc(0,f)) |
| 10710 | ✗ | new_return(8); | |
| 10711 | 365770 | } | |
| 10712 | else | ||
| 10713 | { | ||
| 10714 | 330614 | int format = newtilebuf[start_tile+i].format; | |
| 10715 |
1/2✓ Branch 0 taken 330614 times.
✗ Branch 1 not taken.
|
330614 | if(!p_putc(format,f)) |
| 10716 | { | ||
| 10717 | ✗ | new_return(6); | |
| 10718 | } | ||
| 10719 | |||
| 10720 |
2/2✓ Branch 0 taken 327742 times.
✓ Branch 1 taken 2872 times.
|
330614 | if (format == tf4Bit) |
| 10721 | { | ||
| 10722 | byte temp_tile[128]; | ||
| 10723 | 327742 | byte *di = temp_tile; | |
| 10724 | 327742 | byte *src = newtilebuf[start_tile+i].data; | |
| 10725 |
2/2✓ Branch 0 taken 41950976 times.
✓ Branch 1 taken 327742 times.
|
42278718 | for (int32_t si=0; si<256; si+=2) |
| 10726 | { | ||
| 10727 | 41950976 | *di = (src[si]&15) + ((src[si+1]&15) << 4); | |
| 10728 | 41950976 | ++di; | |
| 10729 | 41950976 | } | |
| 10730 |
1/2✓ Branch 0 taken 327742 times.
✗ Branch 1 not taken.
|
327742 | if (!pfwrite(temp_tile,128,f)) |
| 10731 | { | ||
| 10732 | ✗ | new_return(7); | |
| 10733 | } | ||
| 10734 | 327742 | } | |
| 10735 |
1/2✓ Branch 0 taken 2872 times.
✗ Branch 1 not taken.
|
2872 | else if (!pfwrite(newtilebuf[start_tile+i].data,tilesize(format),f)) |
| 10736 | { | ||
| 10737 | ✗ | new_return(7); | |
| 10738 | } | ||
| 10739 | } | ||
| 10740 | 696384 | } | |
| 10741 | |||
| 10742 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 10743 | { | ||
| 10744 | 9 | section_size=writesize; | |
| 10745 | 9 | } | |
| 10746 | 18 | } | |
| 10747 | |||
| 10748 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 10749 | { | ||
| 10750 | char ebuf[80]; | ||
| 10751 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 10752 | ✗ | jwin_alert("Error: writetiles()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 10753 | ✗ | } | |
| 10754 | |||
| 10755 | 9 | new_return(0); | |
| 10756 | } | ||
| 10757 | |||
| 10758 | /* MIDI Format | ||
| 10759 | section_id LONG | ||
| 10760 | section_version WORD | ||
| 10761 | section_cversion WORD | ||
| 10762 | section_size LONG | ||
| 10763 | midi_flags 32 Byte ? BITFIELD[252] | ||
| 10764 | |||
| 10765 | [ | ||
| 10766 | title 36 | ||
| 10767 | start 4 | ||
| 10768 | loop_start 4 | ||
| 10769 | loop_end 4 | ||
| 10770 | loop 2 | ||
| 10771 | volume 2 | ||
| 10772 | midi * | ||
| 10773 | ] | ||
| 10774 | |||
| 10775 | */ | ||
| 10776 | |||
| 10777 | 9 | int32_t writemidis(PACKFILE *f) | |
| 10778 | { | ||
| 10779 | 9 | dword section_id=ID_MIDIS; | |
| 10780 | 9 | dword section_version=V_MIDIS; | |
| 10781 | 9 | dword section_size = 0; | |
| 10782 | |||
| 10783 | //section id | ||
| 10784 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 10785 | { | ||
| 10786 | ✗ | new_return(1); | |
| 10787 | } | ||
| 10788 | |||
| 10789 | //section version info | ||
| 10790 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 10791 | { | ||
| 10792 | ✗ | new_return(2); | |
| 10793 | } | ||
| 10794 | |||
| 10795 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 10796 | { | ||
| 10797 | ✗ | new_return(3); | |
| 10798 | } | ||
| 10799 | |||
| 10800 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 10801 | { | ||
| 10802 | 18 | fake_pack_writing=(writecycle==0); | |
| 10803 | |||
| 10804 | //section size | ||
| 10805 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 10806 | { | ||
| 10807 | ✗ | new_return(4); | |
| 10808 | } | ||
| 10809 | |||
| 10810 | 18 | writesize=0; | |
| 10811 | |||
| 10812 | //finally... section data | ||
| 10813 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(midi_flags,sizeof(midi_flags),f)) |
| 10814 | { | ||
| 10815 | ✗ | new_return(5); | |
| 10816 | } | ||
| 10817 | |||
| 10818 |
2/2✓ Branch 0 taken 4536 times.
✓ Branch 1 taken 18 times.
|
4554 | for(int32_t i=0; i<MAXCUSTOMMIDIS; i++) |
| 10819 | { | ||
| 10820 |
2/2✓ Branch 0 taken 4406 times.
✓ Branch 1 taken 130 times.
|
4536 | if(get_bit(midi_flags,i)) |
| 10821 | { | ||
| 10822 |
1/2✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
|
130 | if(!pfwrite(&customtunes[i].title,sizeof(customtunes[0].title)-1,f)) |
| 10823 | { | ||
| 10824 | ✗ | new_return(6); | |
| 10825 | } | ||
| 10826 | |||
| 10827 |
1/2✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
|
130 | if(!p_iputl(customtunes[i].start,f)) |
| 10828 | { | ||
| 10829 | ✗ | new_return(7); | |
| 10830 | } | ||
| 10831 | |||
| 10832 |
1/2✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
|
130 | if(!p_iputl(customtunes[i].loop_start,f)) |
| 10833 | { | ||
| 10834 | ✗ | new_return(8); | |
| 10835 | } | ||
| 10836 | |||
| 10837 |
1/2✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
|
130 | if(!p_iputl(customtunes[i].loop_end,f)) |
| 10838 | { | ||
| 10839 | ✗ | new_return(9); | |
| 10840 | } | ||
| 10841 | |||
| 10842 |
1/2✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
|
130 | if(!p_iputw(customtunes[i].loop,f)) |
| 10843 | { | ||
| 10844 | ✗ | new_return(10); | |
| 10845 | } | ||
| 10846 | |||
| 10847 |
1/2✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
|
130 | if(!p_iputw(customtunes[i].volume,f)) |
| 10848 | { | ||
| 10849 | ✗ | new_return(11); | |
| 10850 | } | ||
| 10851 | |||
| 10852 |
1/2✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
|
130 | if(!pfwrite(&customtunes[i].flags, sizeof(customtunes[i].flags),f)) |
| 10853 | { | ||
| 10854 | ✗ | new_return(12); | |
| 10855 | } | ||
| 10856 | |||
| 10857 | 130 | byte format = MFORMAT_MIDI; | |
| 10858 |
1/2✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
|
130 | if(!pfwrite(&format, sizeof(format),f)) |
| 10859 | { | ||
| 10860 | ✗ | new_return(13); | |
| 10861 | } | ||
| 10862 | |||
| 10863 |
1/2✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
|
130 | if (!write_midi(customtunes[i].data, f)) new_return(14); |
| 10864 | 130 | } | |
| 10865 | 4536 | } | |
| 10866 | |||
| 10867 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 10868 | { | ||
| 10869 | 9 | section_size=writesize; | |
| 10870 | 9 | } | |
| 10871 | 18 | } | |
| 10872 | |||
| 10873 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 10874 | { | ||
| 10875 | char ebuf[80]; | ||
| 10876 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 10877 | ✗ | jwin_alert("Error: writemidis()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 10878 | ✗ | } | |
| 10879 | |||
| 10880 | 9 | new_return(0); | |
| 10881 | } | ||
| 10882 | |||
| 10883 | 9 | int32_t writecheats(PACKFILE *f, zquestheader *Header) | |
| 10884 | { | ||
| 10885 | 9 | dword section_id=ID_CHEATS; | |
| 10886 | 9 | dword section_version=V_CHEATS; | |
| 10887 | 9 | dword section_size = 0; | |
| 10888 | |||
| 10889 | //section id | ||
| 10890 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 10891 | { | ||
| 10892 | ✗ | new_return(1); | |
| 10893 | } | ||
| 10894 | |||
| 10895 | //section version info | ||
| 10896 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 10897 | { | ||
| 10898 | ✗ | new_return(2); | |
| 10899 | } | ||
| 10900 | |||
| 10901 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 10902 | { | ||
| 10903 | ✗ | new_return(3); | |
| 10904 | } | ||
| 10905 | |||
| 10906 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 10907 | { | ||
| 10908 | 18 | fake_pack_writing=(writecycle==0); | |
| 10909 | |||
| 10910 | //section size | ||
| 10911 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 10912 | { | ||
| 10913 | ✗ | new_return(4); | |
| 10914 | } | ||
| 10915 | |||
| 10916 | 18 | writesize=0; | |
| 10917 | |||
| 10918 | //finally... section data | ||
| 10919 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(Header->data_flags[ZQ_CHEATS2],f)) |
| 10920 | { | ||
| 10921 | ✗ | new_return(5); | |
| 10922 | } | ||
| 10923 | |||
| 10924 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | if(Header->data_flags[ZQ_CHEATS2]) |
| 10925 | { | ||
| 10926 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zcheats.flags,f)) |
| 10927 | { | ||
| 10928 | ✗ | new_return(6); | |
| 10929 | } | ||
| 10930 | |||
| 10931 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite(&zcheats.codes, sizeof(zcheats.codes), f)) |
| 10932 | { | ||
| 10933 | ✗ | new_return(7); | |
| 10934 | } | ||
| 10935 | 18 | } | |
| 10936 | |||
| 10937 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 10938 | { | ||
| 10939 | 9 | section_size=writesize; | |
| 10940 | 9 | } | |
| 10941 | 18 | } | |
| 10942 | |||
| 10943 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 10944 | { | ||
| 10945 | char ebuf[80]; | ||
| 10946 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 10947 | ✗ | jwin_alert("Error: writecheats()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 10948 | ✗ | } | |
| 10949 | |||
| 10950 | 9 | new_return(0); | |
| 10951 | } | ||
| 10952 | |||
| 10953 | 9 | int32_t writeguys(PACKFILE *f, zquestheader *Header) | |
| 10954 | { | ||
| 10955 | //these are here to bypass compiler warnings about unused arguments | ||
| 10956 | 9 | Header=Header; | |
| 10957 | |||
| 10958 | 9 | dword section_id=ID_GUYS; | |
| 10959 | 9 | dword section_version=V_GUYS; | |
| 10960 | 9 | dword section_size=0; | |
| 10961 | |||
| 10962 | //section id | ||
| 10963 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 10964 | { | ||
| 10965 | ✗ | new_return(1); | |
| 10966 | } | ||
| 10967 | |||
| 10968 | //section version info | ||
| 10969 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 10970 | { | ||
| 10971 | ✗ | new_return(2); | |
| 10972 | } | ||
| 10973 | |||
| 10974 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 10975 | { | ||
| 10976 | ✗ | new_return(3); | |
| 10977 | } | ||
| 10978 | |||
| 10979 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 10980 | { | ||
| 10981 | 18 | fake_pack_writing=(writecycle==0); | |
| 10982 | |||
| 10983 | //section size | ||
| 10984 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 10985 | { | ||
| 10986 | ✗ | new_return(4); | |
| 10987 | } | ||
| 10988 | |||
| 10989 | 18 | writesize=0; | |
| 10990 | |||
| 10991 | //finally... section data | ||
| 10992 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
|
9234 | for(int32_t i=0; i<MAXGUYS; i++) |
| 10993 | { | ||
| 10994 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!pfwrite((char *)guy_string[i], 64, f)) |
| 10995 | { | ||
| 10996 | ✗ | new_return(5); | |
| 10997 | } | ||
| 10998 | 9216 | } | |
| 10999 | |||
| 11000 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
|
9234 | for(int32_t i=0; i<MAXGUYS; i++) |
| 11001 | { | ||
| 11002 | 9216 | uint32_t flags1 = uint32_t(guysbuf[i].flags); | |
| 11003 | 9216 | uint32_t flags2 = uint32_t(guysbuf[i].flags >> 32ULL); | |
| 11004 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(flags1, f)) |
| 11005 | { | ||
| 11006 | ✗ | new_return(6); | |
| 11007 | } | ||
| 11008 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(flags2, f)) |
| 11009 | { | ||
| 11010 | ✗ | new_return(7); | |
| 11011 | } | ||
| 11012 | |||
| 11013 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].tile,f)) |
| 11014 | { | ||
| 11015 | ✗ | new_return(8); | |
| 11016 | } | ||
| 11017 | |||
| 11018 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].width,f)) |
| 11019 | { | ||
| 11020 | ✗ | new_return(9); | |
| 11021 | } | ||
| 11022 | |||
| 11023 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].height,f)) |
| 11024 | { | ||
| 11025 | ✗ | new_return(10); | |
| 11026 | } | ||
| 11027 | |||
| 11028 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].s_tile,f)) |
| 11029 | { | ||
| 11030 | ✗ | new_return(11); | |
| 11031 | } | ||
| 11032 | |||
| 11033 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].s_width,f)) |
| 11034 | { | ||
| 11035 | ✗ | new_return(12); | |
| 11036 | } | ||
| 11037 | |||
| 11038 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].s_height,f)) |
| 11039 | { | ||
| 11040 | ✗ | new_return(13); | |
| 11041 | } | ||
| 11042 | |||
| 11043 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].e_tile,f)) |
| 11044 | { | ||
| 11045 | ✗ | new_return(14); | |
| 11046 | } | ||
| 11047 | |||
| 11048 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].e_width,f)) |
| 11049 | { | ||
| 11050 | ✗ | new_return(15); | |
| 11051 | } | ||
| 11052 | |||
| 11053 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].e_height,f)) |
| 11054 | { | ||
| 11055 | ✗ | new_return(16); | |
| 11056 | } | ||
| 11057 | |||
| 11058 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].hp,f)) |
| 11059 | { | ||
| 11060 | ✗ | new_return(17); | |
| 11061 | } | ||
| 11062 | |||
| 11063 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].family,f)) |
| 11064 | { | ||
| 11065 | ✗ | new_return(18); | |
| 11066 | } | ||
| 11067 | |||
| 11068 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].cset,f)) |
| 11069 | { | ||
| 11070 | ✗ | new_return(19); | |
| 11071 | } | ||
| 11072 | |||
| 11073 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].anim,f)) |
| 11074 | { | ||
| 11075 | ✗ | new_return(20); | |
| 11076 | } | ||
| 11077 | |||
| 11078 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].e_anim,f)) |
| 11079 | { | ||
| 11080 | ✗ | new_return(21); | |
| 11081 | } | ||
| 11082 | |||
| 11083 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].frate,f)) |
| 11084 | { | ||
| 11085 | ✗ | new_return(22); | |
| 11086 | } | ||
| 11087 | |||
| 11088 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].e_frate,f)) |
| 11089 | { | ||
| 11090 | ✗ | new_return(23); | |
| 11091 | } | ||
| 11092 | |||
| 11093 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].dp,f)) |
| 11094 | { | ||
| 11095 | ✗ | new_return(24); | |
| 11096 | } | ||
| 11097 | |||
| 11098 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].wdp,f)) |
| 11099 | { | ||
| 11100 | ✗ | new_return(25); | |
| 11101 | } | ||
| 11102 | |||
| 11103 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].weapon,f)) |
| 11104 | { | ||
| 11105 | ✗ | new_return(26); | |
| 11106 | } | ||
| 11107 | |||
| 11108 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].rate,f)) |
| 11109 | { | ||
| 11110 | ✗ | new_return(27); | |
| 11111 | } | ||
| 11112 | |||
| 11113 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].hrate,f)) |
| 11114 | { | ||
| 11115 | ✗ | new_return(28); | |
| 11116 | } | ||
| 11117 | |||
| 11118 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].step,f)) |
| 11119 | { | ||
| 11120 | ✗ | new_return(29); | |
| 11121 | } | ||
| 11122 | |||
| 11123 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].homing,f)) |
| 11124 | { | ||
| 11125 | ✗ | new_return(30); | |
| 11126 | } | ||
| 11127 | |||
| 11128 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].grumble,f)) |
| 11129 | { | ||
| 11130 | ✗ | new_return(31); | |
| 11131 | } | ||
| 11132 | |||
| 11133 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].item_set,f)) |
| 11134 | { | ||
| 11135 | ✗ | new_return(32); | |
| 11136 | } | ||
| 11137 | |||
| 11138 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[0], f)) |
| 11139 | { | ||
| 11140 | ✗ | new_return(33); | |
| 11141 | } | ||
| 11142 | |||
| 11143 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[1],f)) |
| 11144 | { | ||
| 11145 | ✗ | new_return(34); | |
| 11146 | } | ||
| 11147 | |||
| 11148 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[2],f)) |
| 11149 | { | ||
| 11150 | ✗ | new_return(35); | |
| 11151 | } | ||
| 11152 | |||
| 11153 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[3],f)) |
| 11154 | { | ||
| 11155 | ✗ | new_return(36); | |
| 11156 | } | ||
| 11157 | |||
| 11158 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[4],f)) |
| 11159 | { | ||
| 11160 | ✗ | new_return(37); | |
| 11161 | } | ||
| 11162 | |||
| 11163 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[5],f)) |
| 11164 | { | ||
| 11165 | ✗ | new_return(38); | |
| 11166 | } | ||
| 11167 | |||
| 11168 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[6],f)) |
| 11169 | { | ||
| 11170 | ✗ | new_return(39); | |
| 11171 | } | ||
| 11172 | |||
| 11173 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[7],f)) |
| 11174 | { | ||
| 11175 | ✗ | new_return(40); | |
| 11176 | } | ||
| 11177 | |||
| 11178 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[8],f)) |
| 11179 | { | ||
| 11180 | ✗ | new_return(41); | |
| 11181 | } | ||
| 11182 | |||
| 11183 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[9],f)) |
| 11184 | { | ||
| 11185 | ✗ | new_return(42); | |
| 11186 | } | ||
| 11187 | |||
| 11188 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].bgsfx,f)) |
| 11189 | { | ||
| 11190 | ✗ | new_return(43); | |
| 11191 | } | ||
| 11192 | |||
| 11193 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].bosspal,f)) |
| 11194 | { | ||
| 11195 | ✗ | new_return(44); | |
| 11196 | } | ||
| 11197 | |||
| 11198 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].extend,f)) |
| 11199 | { | ||
| 11200 | ✗ | new_return(45); | |
| 11201 | } | ||
| 11202 | |||
| 11203 |
2/2✓ Branch 0 taken 175104 times.
✓ Branch 1 taken 9216 times.
|
184320 | for(int32_t j=0; j < edefLAST; j++) |
| 11204 | { | ||
| 11205 |
1/2✓ Branch 0 taken 175104 times.
✗ Branch 1 not taken.
|
175104 | if(!p_putc(guysbuf[i].defense[j],f)) |
| 11206 | { | ||
| 11207 | ✗ | new_return(46); | |
| 11208 | } | ||
| 11209 | 175104 | } | |
| 11210 | |||
| 11211 |
5/6✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6144 times.
✓ Branch 3 taken 3072 times.
✓ Branch 4 taken 2048 times.
✓ Branch 5 taken 4096 times.
|
9216 | if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 || (( FFCore.getQuestHeaderInfo(vZelda) == 0x250 ) && FFCore.getQuestHeaderInfo(vBuild) < 32 ) ) |
| 11212 | { | ||
| 11213 | //If no user-set hit sound was in place, and the quest was made in a version before 2.53.0 Gamma 2: | ||
| 11214 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
|
2048 | if ( guysbuf[i].hitsfx == 0 ) guysbuf[i].hitsfx = WAV_EHIT; //Fix quests using the wrong hit sound when loading this. |
| 11215 | //Force SFX_HIT here. | ||
| 11216 | |||
| 11217 | 2048 | } | |
| 11218 | |||
| 11219 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].hitsfx,f)) |
| 11220 | { | ||
| 11221 | ✗ | new_return(47); | |
| 11222 | } | ||
| 11223 | |||
| 11224 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].deadsfx,f)) |
| 11225 | { | ||
| 11226 | ✗ | new_return(48); | |
| 11227 | } | ||
| 11228 | |||
| 11229 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[10],f)) |
| 11230 | { | ||
| 11231 | ✗ | new_return(49); | |
| 11232 | } | ||
| 11233 | |||
| 11234 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[11],f)) |
| 11235 | { | ||
| 11236 | ✗ | new_return(50); | |
| 11237 | } | ||
| 11238 | |||
| 11239 | //New 2.6 defences | ||
| 11240 |
2/2✓ Branch 0 taken 202752 times.
✓ Branch 1 taken 9216 times.
|
211968 | for(int32_t j=edefLAST; j < edefLAST255; j++) |
| 11241 | { | ||
| 11242 |
1/2✓ Branch 0 taken 202752 times.
✗ Branch 1 not taken.
|
202752 | if(!p_putc(guysbuf[i].defense[j],f)) |
| 11243 | { | ||
| 11244 | ✗ | new_return(51); | |
| 11245 | } | ||
| 11246 | 202752 | } | |
| 11247 | |||
| 11248 | //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs | ||
| 11249 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].txsz,f)) |
| 11250 | { | ||
| 11251 | ✗ | new_return(52); | |
| 11252 | } | ||
| 11253 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].tysz,f)) |
| 11254 | { | ||
| 11255 | ✗ | new_return(53); | |
| 11256 | } | ||
| 11257 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].hxsz,f)) |
| 11258 | { | ||
| 11259 | ✗ | new_return(54); | |
| 11260 | } | ||
| 11261 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].hysz,f)) |
| 11262 | { | ||
| 11263 | ✗ | new_return(55); | |
| 11264 | } | ||
| 11265 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].hzsz,f)) |
| 11266 | { | ||
| 11267 | ✗ | new_return(56); | |
| 11268 | } | ||
| 11269 | // These are not fixed types, but ints, so they are safe to use here. | ||
| 11270 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].hxofs,f)) |
| 11271 | { | ||
| 11272 | ✗ | new_return(57); | |
| 11273 | } | ||
| 11274 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].hyofs,f)) |
| 11275 | { | ||
| 11276 | ✗ | new_return(58); | |
| 11277 | } | ||
| 11278 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].xofs,f)) |
| 11279 | { | ||
| 11280 | ✗ | new_return(59); | |
| 11281 | } | ||
| 11282 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].yofs,f)) |
| 11283 | { | ||
| 11284 | ✗ | new_return(60); | |
| 11285 | } | ||
| 11286 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].zofs,f)) |
| 11287 | { | ||
| 11288 | ✗ | new_return(61); | |
| 11289 | } | ||
| 11290 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].wpnsprite,f)) |
| 11291 | { | ||
| 11292 | ✗ | new_return(62); | |
| 11293 | } | ||
| 11294 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].SIZEflags,f)) |
| 11295 | { | ||
| 11296 | ✗ | new_return(63); | |
| 11297 | } | ||
| 11298 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].frozentile,f)) |
| 11299 | { | ||
| 11300 | ✗ | new_return(64); | |
| 11301 | } | ||
| 11302 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].frozencset,f)) |
| 11303 | { | ||
| 11304 | ✗ | new_return(65); | |
| 11305 | } | ||
| 11306 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].frozenclock,f)) |
| 11307 | { | ||
| 11308 | ✗ | new_return(66); | |
| 11309 | } | ||
| 11310 | |||
| 11311 |
2/2✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 9216 times.
|
101376 | for ( int32_t q = 0; q < 10; q++ ) |
| 11312 | { | ||
| 11313 |
1/2✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
|
92160 | if(!p_iputw(guysbuf[i].frozenmisc[q],f)) |
| 11314 | { | ||
| 11315 | ✗ | new_return(67); | |
| 11316 | } | ||
| 11317 | 92160 | } | |
| 11318 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].firesfx,f)) |
| 11319 | { | ||
| 11320 | ✗ | new_return(68); | |
| 11321 | } | ||
| 11322 | //misc 16->31 | ||
| 11323 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[15],f)) |
| 11324 | { | ||
| 11325 | ✗ | new_return(69); | |
| 11326 | } | ||
| 11327 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[16],f)) |
| 11328 | { | ||
| 11329 | ✗ | new_return(70); | |
| 11330 | } | ||
| 11331 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[17],f)) |
| 11332 | { | ||
| 11333 | ✗ | new_return(71); | |
| 11334 | } | ||
| 11335 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[18],f)) |
| 11336 | { | ||
| 11337 | ✗ | new_return(72); | |
| 11338 | } | ||
| 11339 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[19],f)) |
| 11340 | { | ||
| 11341 | ✗ | new_return(73); | |
| 11342 | } | ||
| 11343 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[20],f)) |
| 11344 | { | ||
| 11345 | ✗ | new_return(74); | |
| 11346 | } | ||
| 11347 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[21],f)) |
| 11348 | { | ||
| 11349 | ✗ | new_return(75); | |
| 11350 | } | ||
| 11351 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[22],f)) |
| 11352 | { | ||
| 11353 | ✗ | new_return(76); | |
| 11354 | } | ||
| 11355 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[23],f)) |
| 11356 | { | ||
| 11357 | ✗ | new_return(77); | |
| 11358 | } | ||
| 11359 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[24],f)) |
| 11360 | { | ||
| 11361 | ✗ | new_return(78); | |
| 11362 | } | ||
| 11363 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[25],f)) |
| 11364 | { | ||
| 11365 | ✗ | new_return(79); | |
| 11366 | } | ||
| 11367 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[26],f)) |
| 11368 | { | ||
| 11369 | ✗ | new_return(80); | |
| 11370 | } | ||
| 11371 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[27],f)) |
| 11372 | { | ||
| 11373 | ✗ | new_return(81); | |
| 11374 | } | ||
| 11375 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[28],f)) |
| 11376 | { | ||
| 11377 | ✗ | new_return(82); | |
| 11378 | } | ||
| 11379 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[29],f)) |
| 11380 | { | ||
| 11381 | ✗ | new_return(83); | |
| 11382 | } | ||
| 11383 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[30],f)) |
| 11384 | { | ||
| 11385 | ✗ | new_return(84); | |
| 11386 | } | ||
| 11387 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[31],f)) |
| 11388 | { | ||
| 11389 | ✗ | new_return(85); | |
| 11390 | } | ||
| 11391 |
2/2✓ Branch 0 taken 294912 times.
✓ Branch 1 taken 9216 times.
|
304128 | for ( int32_t q = 0; q < 32; q++ ) |
| 11392 | { | ||
| 11393 |
1/2✓ Branch 0 taken 294912 times.
✗ Branch 1 not taken.
|
294912 | if(!p_iputl(guysbuf[i].movement[q],f)) |
| 11394 | { | ||
| 11395 | ✗ | new_return(86); | |
| 11396 | } | ||
| 11397 | 294912 | } | |
| 11398 |
2/2✓ Branch 0 taken 294912 times.
✓ Branch 1 taken 9216 times.
|
304128 | for ( int32_t q = 0; q < 32; q++ ) |
| 11399 | { | ||
| 11400 |
1/2✓ Branch 0 taken 294912 times.
✗ Branch 1 not taken.
|
294912 | if(!p_iputl(guysbuf[i].new_weapon[q],f)) |
| 11401 | { | ||
| 11402 | ✗ | new_return(87); | |
| 11403 | } | ||
| 11404 | 294912 | } | |
| 11405 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].script,f)) |
| 11406 | { | ||
| 11407 | ✗ | new_return(88); | |
| 11408 | } | ||
| 11409 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
|
82944 | for ( int32_t q = 0; q < 8; q++ ) |
| 11410 | { | ||
| 11411 |
1/2✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
|
73728 | if(!p_iputl(guysbuf[i].initD[q],f)) |
| 11412 | { | ||
| 11413 | ✗ | new_return(89); | |
| 11414 | } | ||
| 11415 | 73728 | } | |
| 11416 |
2/2✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
|
27648 | for ( int32_t q = 0; q < 2; q++ ) |
| 11417 | { | ||
| 11418 |
1/2✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
|
18432 | if(!p_iputl(0,f)) |
| 11419 | { | ||
| 11420 | ✗ | new_return(90); | |
| 11421 | } | ||
| 11422 | 18432 | } | |
| 11423 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].editorflags,f)) |
| 11424 | { | ||
| 11425 | ✗ | new_return(91); | |
| 11426 | } | ||
| 11427 | //somehow forgot these in the older builds -Z | ||
| 11428 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[12],f)) |
| 11429 | { | ||
| 11430 | ✗ | new_return(92); | |
| 11431 | } | ||
| 11432 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[13],f)) |
| 11433 | { | ||
| 11434 | ✗ | new_return(93); | |
| 11435 | } | ||
| 11436 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].attributes[14],f)) |
| 11437 | { | ||
| 11438 | ✗ | new_return(94); | |
| 11439 | } | ||
| 11440 | |||
| 11441 | //Enemy Editor InitD[] labels | ||
| 11442 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
|
82944 | for ( int32_t q = 0; q < 8; q++ ) |
| 11443 | { | ||
| 11444 |
2/2✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
|
4866048 | for ( int32_t w = 0; w < 65; w++ ) |
| 11445 | { | ||
| 11446 |
1/2✓ Branch 0 taken 4792320 times.
✗ Branch 1 not taken.
|
4792320 | if(!p_putc(guysbuf[i].initD_label[q][w],f)) |
| 11447 | { | ||
| 11448 | ✗ | new_return(95); | |
| 11449 | } | ||
| 11450 | 4792320 | } | |
| 11451 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 4792320 times.
|
4866048 | for ( int32_t w = 0; w < 65; w++ ) |
| 11452 | { | ||
| 11453 |
1/2✓ Branch 0 taken 4792320 times.
✗ Branch 1 not taken.
|
4792320 | if(!p_putc(guysbuf[i].weapon_initD_label[q][w],f)) |
| 11454 | { | ||
| 11455 | ✗ | new_return(96); | |
| 11456 | } | ||
| 11457 | 4792320 | } | |
| 11458 | 73728 | } | |
| 11459 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputw(guysbuf[i].weaponscript,f)) |
| 11460 | { | ||
| 11461 | ✗ | new_return(97); | |
| 11462 | } | ||
| 11463 | //eweapon initD | ||
| 11464 |
2/2✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
|
82944 | for ( int32_t q = 0; q < 8; q++ ) |
| 11465 | { | ||
| 11466 |
1/2✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
|
73728 | if(!p_iputl(guysbuf[i].weap_initiald[q],f)) |
| 11467 | { | ||
| 11468 | ✗ | new_return(98); | |
| 11469 | } | ||
| 11470 | 73728 | } | |
| 11471 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_iputl(guysbuf[i].moveflags,f)) |
| 11472 | ✗ | new_return(99); | |
| 11473 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].spr_shadow,f)) |
| 11474 | ✗ | new_return(100); | |
| 11475 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].spr_death,f)) |
| 11476 | ✗ | new_return(101); | |
| 11477 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if(!p_putc(guysbuf[i].spr_spawn,f)) |
| 11478 | ✗ | new_return(102); | |
| 11479 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_putc(guysbuf[i].wunblockable, f)) |
| 11480 | ✗ | new_return(103); | |
| 11481 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].wmoveflags, f)) |
| 11482 | ✗ | new_return(104); | |
| 11483 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].weapoverrideFLAGS, f)) |
| 11484 | ✗ | new_return(105); | |
| 11485 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].weap_tilew, f)) |
| 11486 | ✗ | new_return(106); | |
| 11487 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].weap_tileh, f)) |
| 11488 | ✗ | new_return(107); | |
| 11489 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].weap_hxsz, f)) |
| 11490 | ✗ | new_return(108); | |
| 11491 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].weap_hysz, f)) |
| 11492 | ✗ | new_return(109); | |
| 11493 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].weap_hzsz, f)) |
| 11494 | ✗ | new_return(110); | |
| 11495 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].weap_hxofs, f)) |
| 11496 | ✗ | new_return(111); | |
| 11497 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].weap_hyofs, f)) |
| 11498 | ✗ | new_return(112); | |
| 11499 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].weap_xofs, f)) |
| 11500 | ✗ | new_return(113); | |
| 11501 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].weap_yofs, f)) |
| 11502 | ✗ | new_return(114); | |
| 11503 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_iputl(guysbuf[i].wstep, f)) |
| 11504 | ✗ | new_return(115); | |
| 11505 |
2/2✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 9216 times.
|
55296 | for(int32_t q = 0; q < WPNSPR_MAX; ++q) |
| 11506 | { | ||
| 11507 |
1/2✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
|
46080 | if (!p_iputw(guysbuf[i].burnsprs[q], f)) |
| 11508 | ✗ | new_return(116); | |
| 11509 |
1/2✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
|
46080 | if (!p_iputw(guysbuf[i].light_rads[q], f)) |
| 11510 | ✗ | new_return(117); | |
| 11511 | 46080 | } | |
| 11512 |
1/2✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
|
9216 | if (!p_putc(guysbuf[i].specialsfx, f)) |
| 11513 | ✗ | new_return(118); | |
| 11514 | 9216 | } | |
| 11515 | |||
| 11516 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 11517 | { | ||
| 11518 | 9 | section_size=writesize; | |
| 11519 | 9 | } | |
| 11520 | 18 | } | |
| 11521 | |||
| 11522 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 11523 | { | ||
| 11524 | char ebuf[80]; | ||
| 11525 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 11526 | ✗ | jwin_alert("Error: writeguys()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 11527 | ✗ | } | |
| 11528 | |||
| 11529 | 9 | new_return(0); | |
| 11530 | } | ||
| 11531 | |||
| 11532 | 9 | int32_t writeherosprites(PACKFILE *f, zquestheader *Header) | |
| 11533 | { | ||
| 11534 | //these are here to bypass compiler warnings about unused arguments | ||
| 11535 | 9 | Header=Header; | |
| 11536 | |||
| 11537 | 9 | dword section_id=ID_HEROSPRITES; | |
| 11538 | 9 | dword section_version=V_HEROSPRITES; | |
| 11539 | 9 | dword section_size=0; | |
| 11540 | |||
| 11541 | //section id | ||
| 11542 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 11543 | { | ||
| 11544 | ✗ | new_return(1); | |
| 11545 | } | ||
| 11546 | |||
| 11547 | //section version info | ||
| 11548 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 11549 | { | ||
| 11550 | ✗ | new_return(2); | |
| 11551 | } | ||
| 11552 | |||
| 11553 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 11554 | { | ||
| 11555 | ✗ | new_return(3); | |
| 11556 | } | ||
| 11557 | |||
| 11558 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 11559 | { | ||
| 11560 | 18 | fake_pack_writing=(writecycle==0); | |
| 11561 | |||
| 11562 | //section size | ||
| 11563 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 11564 | { | ||
| 11565 | ✗ | new_return(4); | |
| 11566 | } | ||
| 11567 | |||
| 11568 | 18 | writesize=0; | |
| 11569 | |||
| 11570 | //finally... section data | ||
| 11571 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 11572 | { | ||
| 11573 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(walkspr[i][spr_tile],f)) |
| 11574 | { | ||
| 11575 | ✗ | new_return(5); | |
| 11576 | } | ||
| 11577 | |||
| 11578 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)walkspr[i][spr_flip],f)) |
| 11579 | { | ||
| 11580 | ✗ | new_return(5); | |
| 11581 | } | ||
| 11582 | |||
| 11583 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)walkspr[i][spr_extend],f)) |
| 11584 | { | ||
| 11585 | ✗ | new_return(5); | |
| 11586 | } | ||
| 11587 | 72 | } | |
| 11588 | |||
| 11589 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 11590 | { | ||
| 11591 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(stabspr[i][spr_tile],f)) |
| 11592 | { | ||
| 11593 | ✗ | new_return(6); | |
| 11594 | } | ||
| 11595 | |||
| 11596 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)stabspr[i][spr_flip],f)) |
| 11597 | { | ||
| 11598 | ✗ | new_return(6); | |
| 11599 | } | ||
| 11600 | |||
| 11601 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)stabspr[i][spr_extend],f)) |
| 11602 | { | ||
| 11603 | ✗ | new_return(6); | |
| 11604 | } | ||
| 11605 | 72 | } | |
| 11606 | |||
| 11607 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 11608 | { | ||
| 11609 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(slashspr[i][spr_tile],f)) |
| 11610 | { | ||
| 11611 | ✗ | new_return(7); | |
| 11612 | } | ||
| 11613 | |||
| 11614 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)slashspr[i][spr_flip],f)) |
| 11615 | { | ||
| 11616 | ✗ | new_return(7); | |
| 11617 | } | ||
| 11618 | |||
| 11619 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)slashspr[i][spr_extend],f)) |
| 11620 | { | ||
| 11621 | ✗ | new_return(7); | |
| 11622 | } | ||
| 11623 | 72 | } | |
| 11624 | |||
| 11625 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 11626 | { | ||
| 11627 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(floatspr[i][spr_tile],f)) |
| 11628 | { | ||
| 11629 | ✗ | new_return(8); | |
| 11630 | } | ||
| 11631 | |||
| 11632 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)floatspr[i][spr_flip],f)) |
| 11633 | { | ||
| 11634 | ✗ | new_return(8); | |
| 11635 | } | ||
| 11636 | |||
| 11637 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)floatspr[i][spr_extend],f)) |
| 11638 | { | ||
| 11639 | ✗ | new_return(8); | |
| 11640 | } | ||
| 11641 | 72 | } | |
| 11642 | |||
| 11643 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 11644 | { | ||
| 11645 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(swimspr[i][spr_tile],f)) |
| 11646 | { | ||
| 11647 | ✗ | new_return(8); | |
| 11648 | } | ||
| 11649 | |||
| 11650 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)swimspr[i][spr_flip],f)) |
| 11651 | { | ||
| 11652 | ✗ | new_return(8); | |
| 11653 | } | ||
| 11654 | |||
| 11655 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)swimspr[i][spr_extend],f)) |
| 11656 | { | ||
| 11657 | ✗ | new_return(8); | |
| 11658 | } | ||
| 11659 | 72 | } | |
| 11660 | |||
| 11661 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 11662 | { | ||
| 11663 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(divespr[i][spr_tile],f)) |
| 11664 | { | ||
| 11665 | ✗ | new_return(9); | |
| 11666 | } | ||
| 11667 | |||
| 11668 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)divespr[i][spr_flip],f)) |
| 11669 | { | ||
| 11670 | ✗ | new_return(9); | |
| 11671 | } | ||
| 11672 | |||
| 11673 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)divespr[i][spr_extend],f)) |
| 11674 | { | ||
| 11675 | ✗ | new_return(9); | |
| 11676 | } | ||
| 11677 | 72 | } | |
| 11678 | |||
| 11679 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 11680 | { | ||
| 11681 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(poundspr[i][spr_tile],f)) |
| 11682 | { | ||
| 11683 | ✗ | new_return(10); | |
| 11684 | } | ||
| 11685 | |||
| 11686 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)poundspr[i][spr_flip],f)) |
| 11687 | { | ||
| 11688 | ✗ | new_return(10); | |
| 11689 | } | ||
| 11690 | |||
| 11691 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)poundspr[i][spr_extend],f)) |
| 11692 | { | ||
| 11693 | ✗ | new_return(10); | |
| 11694 | } | ||
| 11695 | 72 | } | |
| 11696 | |||
| 11697 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(castingspr[spr_tile],f)) |
| 11698 | { | ||
| 11699 | ✗ | new_return(11); | |
| 11700 | } | ||
| 11701 | |||
| 11702 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc((byte)castingspr[spr_flip],f)) |
| 11703 | { | ||
| 11704 | ✗ | new_return(11); | |
| 11705 | } | ||
| 11706 | |||
| 11707 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc((byte)castingspr[spr_extend],f)) |
| 11708 | { | ||
| 11709 | ✗ | new_return(11); | |
| 11710 | } | ||
| 11711 | |||
| 11712 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 18 times.
|
54 | for(int32_t i=0; i<2; i++) |
| 11713 | { | ||
| 11714 |
2/2✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
|
144 | for(int32_t j=0; j<spr_holdmax; j++) |
| 11715 | { | ||
| 11716 |
1/2✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
|
108 | if(!p_iputl(holdspr[i][j][spr_tile],f)) |
| 11717 | { | ||
| 11718 | ✗ | new_return(12); | |
| 11719 | } | ||
| 11720 | |||
| 11721 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
|
108 | if(!p_putc((byte)holdspr[i][j][spr_flip],f)) |
| 11722 | { | ||
| 11723 | ✗ | new_return(12); | |
| 11724 | } | ||
| 11725 | |||
| 11726 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
|
108 | if(!p_putc((byte)holdspr[i][j][spr_extend],f)) |
| 11727 | { | ||
| 11728 | ✗ | new_return(12); | |
| 11729 | } | ||
| 11730 | 108 | } | |
| 11731 | 36 | } | |
| 11732 | |||
| 11733 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 11734 | { | ||
| 11735 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(jumpspr[i][spr_tile],f)) |
| 11736 | { | ||
| 11737 | ✗ | new_return(13); | |
| 11738 | } | ||
| 11739 | |||
| 11740 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)jumpspr[i][spr_flip],f)) |
| 11741 | { | ||
| 11742 | ✗ | new_return(13); | |
| 11743 | } | ||
| 11744 | |||
| 11745 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)jumpspr[i][spr_extend],f)) |
| 11746 | { | ||
| 11747 | ✗ | new_return(13); | |
| 11748 | } | ||
| 11749 | 72 | } | |
| 11750 | |||
| 11751 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 11752 | { | ||
| 11753 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(chargespr[i][spr_tile],f)) |
| 11754 | { | ||
| 11755 | ✗ | new_return(13); | |
| 11756 | } | ||
| 11757 | |||
| 11758 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)chargespr[i][spr_flip],f)) |
| 11759 | { | ||
| 11760 | ✗ | new_return(13); | |
| 11761 | } | ||
| 11762 | |||
| 11763 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)chargespr[i][spr_extend],f)) |
| 11764 | { | ||
| 11765 | ✗ | new_return(13); | |
| 11766 | } | ||
| 11767 | 72 | } | |
| 11768 | |||
| 11769 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc((byte)zinit.hero_swim_speed,f)) |
| 11770 | { | ||
| 11771 | ✗ | new_return(14); | |
| 11772 | } | ||
| 11773 | |||
| 11774 | //{ V_HEROSPRITES >= 7 | ||
| 11775 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11776 | { | ||
| 11777 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(frozenspr[q][spr_tile],f)) |
| 11778 | ✗ | new_return(15); | |
| 11779 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)frozenspr[q][spr_flip],f)) |
| 11780 | ✗ | new_return(15); | |
| 11781 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)frozenspr[q][spr_extend],f)) |
| 11782 | ✗ | new_return(15); | |
| 11783 | 72 | } | |
| 11784 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11785 | { | ||
| 11786 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(frozen_waterspr[q][spr_tile],f)) |
| 11787 | ✗ | new_return(15); | |
| 11788 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)frozen_waterspr[q][spr_flip],f)) |
| 11789 | ✗ | new_return(15); | |
| 11790 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)frozen_waterspr[q][spr_extend],f)) |
| 11791 | ✗ | new_return(15); | |
| 11792 | 72 | } | |
| 11793 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11794 | { | ||
| 11795 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(onfirespr[q][spr_tile],f)) |
| 11796 | ✗ | new_return(15); | |
| 11797 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)onfirespr[q][spr_flip],f)) |
| 11798 | ✗ | new_return(15); | |
| 11799 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)onfirespr[q][spr_extend],f)) |
| 11800 | ✗ | new_return(15); | |
| 11801 | 72 | } | |
| 11802 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11803 | { | ||
| 11804 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(onfire_waterspr[q][spr_tile],f)) |
| 11805 | ✗ | new_return(15); | |
| 11806 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)onfire_waterspr[q][spr_flip],f)) |
| 11807 | ✗ | new_return(15); | |
| 11808 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)onfire_waterspr[q][spr_extend],f)) |
| 11809 | ✗ | new_return(15); | |
| 11810 | 72 | } | |
| 11811 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11812 | { | ||
| 11813 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(diggingspr[q][spr_tile],f)) |
| 11814 | ✗ | new_return(15); | |
| 11815 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)diggingspr[q][spr_flip],f)) |
| 11816 | ✗ | new_return(15); | |
| 11817 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)diggingspr[q][spr_extend],f)) |
| 11818 | ✗ | new_return(15); | |
| 11819 | 72 | } | |
| 11820 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11821 | { | ||
| 11822 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(usingrodspr[q][spr_tile],f)) |
| 11823 | ✗ | new_return(15); | |
| 11824 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)usingrodspr[q][spr_flip],f)) |
| 11825 | ✗ | new_return(15); | |
| 11826 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)usingrodspr[q][spr_extend],f)) |
| 11827 | ✗ | new_return(15); | |
| 11828 | 72 | } | |
| 11829 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11830 | { | ||
| 11831 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(usingcanespr[q][spr_tile],f)) |
| 11832 | ✗ | new_return(15); | |
| 11833 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)usingcanespr[q][spr_flip],f)) |
| 11834 | ✗ | new_return(15); | |
| 11835 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)usingcanespr[q][spr_extend],f)) |
| 11836 | ✗ | new_return(15); | |
| 11837 | 72 | } | |
| 11838 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11839 | { | ||
| 11840 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(pushingspr[q][spr_tile],f)) |
| 11841 | ✗ | new_return(15); | |
| 11842 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)pushingspr[q][spr_flip],f)) |
| 11843 | ✗ | new_return(15); | |
| 11844 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)pushingspr[q][spr_extend],f)) |
| 11845 | ✗ | new_return(15); | |
| 11846 | 72 | } | |
| 11847 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11848 | { | ||
| 11849 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(liftingspr[q][spr_tile],f)) |
| 11850 | ✗ | new_return(15); | |
| 11851 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)liftingspr[q][spr_flip],f)) |
| 11852 | ✗ | new_return(15); | |
| 11853 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)liftingspr[q][spr_extend],f)) |
| 11854 | ✗ | new_return(15); | |
| 11855 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)liftingspr[q][spr_frames],f)) |
| 11856 | ✗ | new_return(15); | |
| 11857 | 72 | } | |
| 11858 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11859 | { | ||
| 11860 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(liftingwalkspr[q][spr_tile],f)) |
| 11861 | ✗ | new_return(15); | |
| 11862 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)liftingwalkspr[q][spr_flip],f)) |
| 11863 | ✗ | new_return(15); | |
| 11864 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)liftingwalkspr[q][spr_extend],f)) |
| 11865 | ✗ | new_return(15); | |
| 11866 | 72 | } | |
| 11867 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11868 | { | ||
| 11869 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(stunnedspr[q][spr_tile],f)) |
| 11870 | ✗ | new_return(15); | |
| 11871 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)stunnedspr[q][spr_flip],f)) |
| 11872 | ✗ | new_return(15); | |
| 11873 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)stunnedspr[q][spr_extend],f)) |
| 11874 | ✗ | new_return(15); | |
| 11875 | 72 | } | |
| 11876 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11877 | { | ||
| 11878 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(stunned_waterspr[q][spr_tile],f)) |
| 11879 | ✗ | new_return(15); | |
| 11880 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)stunned_waterspr[q][spr_flip],f)) |
| 11881 | ✗ | new_return(15); | |
| 11882 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)stunned_waterspr[q][spr_extend],f)) |
| 11883 | ✗ | new_return(15); | |
| 11884 | 72 | } | |
| 11885 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11886 | { | ||
| 11887 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(drowningspr[q][spr_tile],f)) |
| 11888 | ✗ | new_return(15); | |
| 11889 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)drowningspr[q][spr_flip],f)) |
| 11890 | ✗ | new_return(15); | |
| 11891 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)drowningspr[q][spr_extend],f)) |
| 11892 | ✗ | new_return(15); | |
| 11893 | 72 | } | |
| 11894 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11895 | { | ||
| 11896 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(drowning_lavaspr[q][spr_tile],f)) |
| 11897 | ✗ | new_return(15); | |
| 11898 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)drowning_lavaspr[q][spr_flip],f)) |
| 11899 | ✗ | new_return(15); | |
| 11900 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)drowning_lavaspr[q][spr_extend],f)) |
| 11901 | ✗ | new_return(15); | |
| 11902 | 72 | } | |
| 11903 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11904 | { | ||
| 11905 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(fallingspr[q][spr_tile],f)) |
| 11906 | ✗ | new_return(15); | |
| 11907 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)fallingspr[q][spr_flip],f)) |
| 11908 | ✗ | new_return(15); | |
| 11909 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)fallingspr[q][spr_extend],f)) |
| 11910 | ✗ | new_return(15); | |
| 11911 | 72 | } | |
| 11912 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11913 | { | ||
| 11914 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(shockedspr[q][spr_tile],f)) |
| 11915 | ✗ | new_return(15); | |
| 11916 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)shockedspr[q][spr_flip],f)) |
| 11917 | ✗ | new_return(15); | |
| 11918 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)shockedspr[q][spr_extend],f)) |
| 11919 | ✗ | new_return(15); | |
| 11920 | 72 | } | |
| 11921 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11922 | { | ||
| 11923 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(shocked_waterspr[q][spr_tile],f)) |
| 11924 | ✗ | new_return(15); | |
| 11925 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)shocked_waterspr[q][spr_flip],f)) |
| 11926 | ✗ | new_return(15); | |
| 11927 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)shocked_waterspr[q][spr_extend],f)) |
| 11928 | ✗ | new_return(15); | |
| 11929 | 72 | } | |
| 11930 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11931 | { | ||
| 11932 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(pullswordspr[q][spr_tile],f)) |
| 11933 | ✗ | new_return(15); | |
| 11934 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)pullswordspr[q][spr_flip],f)) |
| 11935 | ✗ | new_return(15); | |
| 11936 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)pullswordspr[q][spr_extend],f)) |
| 11937 | ✗ | new_return(15); | |
| 11938 | 72 | } | |
| 11939 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11940 | { | ||
| 11941 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(readingspr[q][spr_tile],f)) |
| 11942 | ✗ | new_return(15); | |
| 11943 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)readingspr[q][spr_flip],f)) |
| 11944 | ✗ | new_return(15); | |
| 11945 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)readingspr[q][spr_extend],f)) |
| 11946 | ✗ | new_return(15); | |
| 11947 | 72 | } | |
| 11948 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11949 | { | ||
| 11950 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(slash180spr[q][spr_tile],f)) |
| 11951 | ✗ | new_return(15); | |
| 11952 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)slash180spr[q][spr_flip],f)) |
| 11953 | ✗ | new_return(15); | |
| 11954 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)slash180spr[q][spr_extend],f)) |
| 11955 | ✗ | new_return(15); | |
| 11956 | 72 | } | |
| 11957 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11958 | { | ||
| 11959 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(slashZ4spr[q][spr_tile],f)) |
| 11960 | ✗ | new_return(15); | |
| 11961 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)slashZ4spr[q][spr_flip],f)) |
| 11962 | ✗ | new_return(15); | |
| 11963 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)slashZ4spr[q][spr_extend],f)) |
| 11964 | ✗ | new_return(15); | |
| 11965 | 72 | } | |
| 11966 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11967 | { | ||
| 11968 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(dashspr[q][spr_tile],f)) |
| 11969 | ✗ | new_return(15); | |
| 11970 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)dashspr[q][spr_flip],f)) |
| 11971 | ✗ | new_return(15); | |
| 11972 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)dashspr[q][spr_extend],f)) |
| 11973 | ✗ | new_return(15); | |
| 11974 | 72 | } | |
| 11975 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11976 | { | ||
| 11977 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(bonkspr[q][spr_tile],f)) |
| 11978 | ✗ | new_return(15); | |
| 11979 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)bonkspr[q][spr_flip],f)) |
| 11980 | ✗ | new_return(15); | |
| 11981 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)bonkspr[q][spr_extend],f)) |
| 11982 | ✗ | new_return(15); | |
| 11983 | 72 | } | |
| 11984 |
2/2✓ Branch 0 taken 54 times.
✓ Branch 1 taken 18 times.
|
72 | for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs |
| 11985 | { | ||
| 11986 |
1/2✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
|
54 | if(!p_iputl(medallionsprs[q][spr_tile],f)) |
| 11987 | ✗ | new_return(15); | |
| 11988 |
1/2✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
|
54 | if(!p_putc((byte)medallionsprs[q][spr_flip],f)) |
| 11989 | ✗ | new_return(15); | |
| 11990 |
1/2✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
|
54 | if(!p_putc((byte)medallionsprs[q][spr_extend],f)) |
| 11991 | ✗ | new_return(15); | |
| 11992 | 54 | } | |
| 11993 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 11994 | { | ||
| 11995 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(sideswimspr[q][spr_tile],f)) |
| 11996 | ✗ | new_return(16); | |
| 11997 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sideswimspr[q][spr_flip],f)) |
| 11998 | ✗ | new_return(16); | |
| 11999 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sideswimspr[q][spr_extend],f)) |
| 12000 | ✗ | new_return(16); | |
| 12001 | 72 | } | |
| 12002 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 12003 | { | ||
| 12004 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(sideswimslashspr[q][spr_tile],f)) |
| 12005 | ✗ | new_return(17); | |
| 12006 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sideswimslashspr[q][spr_flip],f)) |
| 12007 | ✗ | new_return(17); | |
| 12008 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sideswimslashspr[q][spr_extend],f)) |
| 12009 | ✗ | new_return(17); | |
| 12010 | 72 | } | |
| 12011 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 12012 | { | ||
| 12013 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(sideswimstabspr[q][spr_tile],f)) |
| 12014 | ✗ | new_return(17); | |
| 12015 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sideswimstabspr[q][spr_flip],f)) |
| 12016 | ✗ | new_return(17); | |
| 12017 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sideswimstabspr[q][spr_extend],f)) |
| 12018 | ✗ | new_return(17); | |
| 12019 | 72 | } | |
| 12020 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 12021 | { | ||
| 12022 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(sideswimpoundspr[q][spr_tile],f)) |
| 12023 | ✗ | new_return(17); | |
| 12024 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sideswimpoundspr[q][spr_flip],f)) |
| 12025 | ✗ | new_return(17); | |
| 12026 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sideswimpoundspr[q][spr_extend],f)) |
| 12027 | ✗ | new_return(17); | |
| 12028 | 72 | } | |
| 12029 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 12030 | { | ||
| 12031 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(sideswimchargespr[q][spr_tile],f)) |
| 12032 | ✗ | new_return(18); | |
| 12033 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sideswimchargespr[q][spr_flip],f)) |
| 12034 | ✗ | new_return(18); | |
| 12035 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sideswimchargespr[q][spr_extend],f)) |
| 12036 | ✗ | new_return(18); | |
| 12037 | 72 | } | |
| 12038 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 12039 | { | ||
| 12040 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(hammeroffsets[q],f)) |
| 12041 | ✗ | new_return(19); | |
| 12042 | 72 | } | |
| 12043 |
2/2✓ Branch 0 taken 54 times.
✓ Branch 1 taken 18 times.
|
72 | for(int32_t q = 0; q < 3; ++q) |
| 12044 | { | ||
| 12045 |
1/2✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
|
54 | if(!p_iputl(sideswimholdspr[q][spr_tile],f)) |
| 12046 | ✗ | new_return(20); | |
| 12047 |
1/2✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
|
54 | if(!p_putc((byte)sideswimholdspr[q][spr_flip],f)) |
| 12048 | ✗ | new_return(20); | |
| 12049 |
1/2✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
|
54 | if(!p_putc((byte)sideswimholdspr[q][spr_extend],f)) |
| 12050 | ✗ | new_return(20); | |
| 12051 | 54 | } | |
| 12052 | |||
| 12053 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(sideswimcastingspr[spr_tile],f)) |
| 12054 | { | ||
| 12055 | ✗ | new_return(21); | |
| 12056 | } | ||
| 12057 | |||
| 12058 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc((byte)sideswimcastingspr[spr_flip],f)) |
| 12059 | { | ||
| 12060 | ✗ | new_return(21); | |
| 12061 | } | ||
| 12062 | |||
| 12063 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc((byte)sideswimcastingspr[spr_extend],f)) |
| 12064 | { | ||
| 12065 | ✗ | new_return(21); | |
| 12066 | } | ||
| 12067 | |||
| 12068 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t q = 0; q < 4; ++q) |
| 12069 | { | ||
| 12070 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(sidedrowningspr[q][spr_tile],f)) |
| 12071 | ✗ | new_return(22); | |
| 12072 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sidedrowningspr[q][spr_flip],f)) |
| 12073 | ✗ | new_return(22); | |
| 12074 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)sidedrowningspr[q][spr_extend],f)) |
| 12075 | ✗ | new_return(22); | |
| 12076 | 72 | } | |
| 12077 | |||
| 12078 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int32_t i=0; i<4; i++) |
| 12079 | { | ||
| 12080 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(revslashspr[i][spr_tile],f)) |
| 12081 | { | ||
| 12082 | ✗ | new_return(23); | |
| 12083 | } | ||
| 12084 | |||
| 12085 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)revslashspr[i][spr_flip],f)) |
| 12086 | { | ||
| 12087 | ✗ | new_return(23); | |
| 12088 | } | ||
| 12089 | |||
| 12090 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_putc((byte)revslashspr[i][spr_extend],f)) |
| 12091 | { | ||
| 12092 | ✗ | new_return(23); | |
| 12093 | } | ||
| 12094 | 72 | } | |
| 12095 | |||
| 12096 | |||
| 12097 |
2/2✓ Branch 0 taken 2628 times.
✓ Branch 1 taken 18 times.
|
2646 | for (int32_t q = 0; q < wMax; q++) // Hero defense values |
| 12098 | { | ||
| 12099 |
1/2✓ Branch 0 taken 2628 times.
✗ Branch 1 not taken.
|
2628 | if (!p_putc(hero_defence[q], f)) |
| 12100 | ✗ | new_return(15); | |
| 12101 | 2628 | } | |
| 12102 | //} | ||
| 12103 | |||
| 12104 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 12105 | { | ||
| 12106 | 9 | section_size=writesize; | |
| 12107 | 9 | } | |
| 12108 | 18 | } | |
| 12109 | |||
| 12110 | //More data will come here | ||
| 12111 | |||
| 12112 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 12113 | { | ||
| 12114 | char ebuf[80]; | ||
| 12115 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 12116 | ✗ | jwin_alert("Error: writeherosprites()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 12117 | ✗ | } | |
| 12118 | |||
| 12119 | 9 | new_return(0); | |
| 12120 | } | ||
| 12121 | |||
| 12122 | 9 | int32_t writesubscreens(PACKFILE *f, zquestheader *Header) | |
| 12123 | { | ||
| 12124 | 9 | dword section_id=ID_SUBSCREEN; | |
| 12125 | 9 | dword section_version=V_SUBSCREEN; | |
| 12126 | 9 | dword section_size=0; | |
| 12127 | |||
| 12128 | //section id | ||
| 12129 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 12130 | { | ||
| 12131 | ✗ | new_return(1); | |
| 12132 | } | ||
| 12133 | |||
| 12134 | //section version info | ||
| 12135 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 12136 | { | ||
| 12137 | ✗ | new_return(2); | |
| 12138 | } | ||
| 12139 | |||
| 12140 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 12141 | { | ||
| 12142 | ✗ | new_return(3); | |
| 12143 | } | ||
| 12144 | |||
| 12145 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 12146 | { | ||
| 12147 | 18 | fake_pack_writing=(writecycle==0); | |
| 12148 | |||
| 12149 | //section size | ||
| 12150 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 12151 | { | ||
| 12152 | ✗ | new_return(4); | |
| 12153 | } | ||
| 12154 | |||
| 12155 | 18 | writesize=0; | |
| 12156 | |||
| 12157 | 18 | byte sz = subscreens_active.size(); | |
| 12158 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(sz,f)) |
| 12159 | ✗ | new_return(5); | |
| 12160 |
2/2✓ Branch 0 taken 86 times.
✓ Branch 1 taken 18 times.
|
104 | for(int32_t i=0; i<sz; i++) |
| 12161 | { | ||
| 12162 | 86 | int32_t ret = subscreens_active[i].write(f); | |
| 12163 | 86 | fake_pack_writing=(writecycle==0); | |
| 12164 | |||
| 12165 |
1/2✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
|
86 | if(ret!=0) |
| 12166 | ✗ | new_return(ret); | |
| 12167 | 86 | } | |
| 12168 | |||
| 12169 | 18 | sz = subscreens_passive.size(); | |
| 12170 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(sz,f)) |
| 12171 | ✗ | new_return(5); | |
| 12172 |
2/2✓ Branch 0 taken 62 times.
✓ Branch 1 taken 18 times.
|
80 | for(int32_t i=0; i<sz; i++) |
| 12173 | { | ||
| 12174 | 62 | int32_t ret = subscreens_passive[i].write(f); | |
| 12175 | 62 | fake_pack_writing=(writecycle==0); | |
| 12176 | |||
| 12177 |
1/2✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
|
62 | if(ret!=0) |
| 12178 | ✗ | new_return(ret); | |
| 12179 | 62 | } | |
| 12180 | |||
| 12181 | 18 | sz = subscreens_overlay.size(); | |
| 12182 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(sz,f)) |
| 12183 | ✗ | new_return(5); | |
| 12184 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | for(int32_t i=0; i<sz; i++) |
| 12185 | { | ||
| 12186 | ✗ | int32_t ret = subscreens_overlay[i].write(f); | |
| 12187 | ✗ | fake_pack_writing=(writecycle==0); | |
| 12188 | |||
| 12189 | ✗ | if(ret!=0) | |
| 12190 | ✗ | new_return(ret); | |
| 12191 | ✗ | } | |
| 12192 | |||
| 12193 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 12194 | { | ||
| 12195 | 9 | section_size=writesize; | |
| 12196 | 9 | } | |
| 12197 | 18 | } | |
| 12198 | |||
| 12199 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 12200 | { | ||
| 12201 | char ebuf[80]; | ||
| 12202 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 12203 | ✗ | jwin_alert("Error: writesubscreens()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 12204 | ✗ | } | |
| 12205 | |||
| 12206 | 9 | new_return(0); | |
| 12207 | 9 | } | |
| 12208 | |||
| 12209 | extern script_data *ffscripts[NUMSCRIPTFFC]; | ||
| 12210 | extern script_data *itemscripts[NUMSCRIPTITEM]; | ||
| 12211 | extern script_data *guyscripts[NUMSCRIPTGUYS]; | ||
| 12212 | extern script_data *lwpnscripts[NUMSCRIPTWEAPONS]; | ||
| 12213 | extern script_data *ewpnscripts[NUMSCRIPTWEAPONS]; | ||
| 12214 | extern script_data *globalscripts[NUMSCRIPTGLOBAL]; | ||
| 12215 | extern script_data *genericscripts[NUMSCRIPTSGENERIC]; | ||
| 12216 | extern script_data *playerscripts[NUMSCRIPTHERO]; | ||
| 12217 | extern script_data *screenscripts[NUMSCRIPTSCREEN]; | ||
| 12218 | extern script_data *dmapscripts[NUMSCRIPTSDMAP]; | ||
| 12219 | extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE]; | ||
| 12220 | extern script_data *comboscripts[NUMSCRIPTSCOMBODATA]; | ||
| 12221 | extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN]; | ||
| 12222 | |||
| 12223 | 9 | int32_t writeffscript(PACKFILE *f, zquestheader *Header) | |
| 12224 | { | ||
| 12225 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
|
9 | if (QMisc.zscript_last_compiled_version <= 26) |
| 12226 | 3 | return writeffscript_old(f, Header); | |
| 12227 | |||
| 12228 | 6 | dword section_id = ID_FFSCRIPT; | |
| 12229 | 6 | dword section_version = V_FFSCRIPT; | |
| 12230 | 6 | dword section_size = 0; | |
| 12231 | 6 | dword zasmmeta_version = METADATA_V; | |
| 12232 | 6 | byte numscripts = 0; | |
| 12233 | 6 | numscripts = numscripts; //to avoid unused variables warnings | |
| 12234 | |||
| 12235 | //section id | ||
| 12236 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if(!p_mputl(section_id,f)) |
| 12237 | { | ||
| 12238 | ✗ | new_return(1); | |
| 12239 | } | ||
| 12240 | |||
| 12241 | //section version info | ||
| 12242 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if(!p_iputw(section_version,f)) |
| 12243 | { | ||
| 12244 | ✗ | new_return(2); | |
| 12245 | } | ||
| 12246 | |||
| 12247 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if(!write_deprecated_section_cversion(section_version,f)) |
| 12248 | { | ||
| 12249 | ✗ | new_return(3); | |
| 12250 | } | ||
| 12251 | |||
| 12252 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if(!p_iputw(zasmmeta_version,f)) |
| 12253 | { | ||
| 12254 | ✗ | new_return(4); | |
| 12255 | } | ||
| 12256 | |||
| 12257 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
|
18 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 12258 | { | ||
| 12259 | 12 | fake_pack_writing=(writecycle==0); | |
| 12260 | |||
| 12261 | //section size | ||
| 12262 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | if(!p_iputl(section_size,f)) |
| 12263 | { | ||
| 12264 | ✗ | new_return(5); | |
| 12265 | } | ||
| 12266 | |||
| 12267 | 12 | writesize=0; | |
| 12268 | |||
| 12269 | 12 | write_quest_zasm(f); | |
| 12270 | |||
| 12271 |
2/2✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
|
6156 | for(int32_t i=0; i<NUMSCRIPTFFC; i++) |
| 12272 | { | ||
| 12273 | 6144 | int32_t ret = write_one_ffscript(f, Header, i, ffscripts[i]); | |
| 12274 | |||
| 12275 |
1/2✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
|
6144 | if(ret!=0) |
| 12276 | { | ||
| 12277 | ✗ | new_return(ret); | |
| 12278 | } | ||
| 12279 | 6144 | } | |
| 12280 | |||
| 12281 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
|
3084 | for(int32_t i=0; i<NUMSCRIPTITEM; i++) |
| 12282 | { | ||
| 12283 | 3072 | int32_t ret = write_one_ffscript(f, Header, i, itemscripts[i]); | |
| 12284 | |||
| 12285 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 12286 | { | ||
| 12287 | ✗ | new_return(ret); | |
| 12288 | } | ||
| 12289 | 3072 | } | |
| 12290 | |||
| 12291 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
|
3084 | for(int32_t i=0; i<NUMSCRIPTGUYS; i++) |
| 12292 | { | ||
| 12293 | 3072 | int32_t ret = write_one_ffscript(f, Header, i, guyscripts[i]); | |
| 12294 | |||
| 12295 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 12296 | { | ||
| 12297 | ✗ | new_return(ret); | |
| 12298 | } | ||
| 12299 | 3072 | } | |
| 12300 | |||
| 12301 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | script_data *fake = new script_data(ScriptType::None, 0); |
| 12302 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
|
3084 | for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++) |
| 12303 | { | ||
| 12304 | 3072 | int32_t ret = write_one_ffscript(f, Header, i, fake); | |
| 12305 | |||
| 12306 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 12307 | { | ||
| 12308 | ✗ | new_return(ret); | |
| 12309 | } | ||
| 12310 | 3072 | } | |
| 12311 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | delete fake; |
| 12312 | |||
| 12313 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
|
3084 | for(int32_t i=0; i<NUMSCRIPTSCREEN; i++) |
| 12314 | { | ||
| 12315 | 3072 | int32_t ret = write_one_ffscript(f, Header, i, screenscripts[i]); | |
| 12316 | |||
| 12317 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 12318 | { | ||
| 12319 | ✗ | new_return(ret); | |
| 12320 | } | ||
| 12321 | 3072 | } | |
| 12322 | |||
| 12323 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12 times.
|
108 | for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++) |
| 12324 | { | ||
| 12325 | 96 | int32_t ret = write_one_ffscript(f, Header, i, globalscripts[i]); | |
| 12326 | |||
| 12327 |
1/2✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
|
96 | if(ret!=0) |
| 12328 | { | ||
| 12329 | ✗ | new_return(ret); | |
| 12330 | } | ||
| 12331 | 96 | } | |
| 12332 | |||
| 12333 |
2/2✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
|
72 | for(int32_t i=0; i<NUMSCRIPTHERO; i++) |
| 12334 | { | ||
| 12335 | 60 | int32_t ret = write_one_ffscript(f, Header, i, playerscripts[i]); | |
| 12336 | |||
| 12337 |
1/2✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
|
60 | if(ret!=0) |
| 12338 | { | ||
| 12339 | ✗ | new_return(ret); | |
| 12340 | } | ||
| 12341 | 60 | } | |
| 12342 | |||
| 12343 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
|
3084 | for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++) |
| 12344 | { | ||
| 12345 | 3072 | int32_t ret = write_one_ffscript(f, Header, i, lwpnscripts[i]); | |
| 12346 | |||
| 12347 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 12348 | { | ||
| 12349 | ✗ | new_return(ret); | |
| 12350 | } | ||
| 12351 | 3072 | } | |
| 12352 | |||
| 12353 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
|
3084 | for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++) |
| 12354 | { | ||
| 12355 | 3072 | int32_t ret = write_one_ffscript(f, Header, i, ewpnscripts[i]); | |
| 12356 | |||
| 12357 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 12358 | { | ||
| 12359 | ✗ | new_return(ret); | |
| 12360 | } | ||
| 12361 | 3072 | } | |
| 12362 | |||
| 12363 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
|
3084 | for(int32_t i=0; i<NUMSCRIPTSDMAP; i++) |
| 12364 | { | ||
| 12365 | 3072 | int32_t ret = write_one_ffscript(f, Header, i, dmapscripts[i]); | |
| 12366 | |||
| 12367 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 12368 | { | ||
| 12369 | ✗ | new_return(ret); | |
| 12370 | } | ||
| 12371 | 3072 | } | |
| 12372 | |||
| 12373 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
|
3084 | for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++) |
| 12374 | { | ||
| 12375 | 3072 | int32_t ret = write_one_ffscript(f, Header, i, itemspritescripts[i]); | |
| 12376 | |||
| 12377 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 12378 | { | ||
| 12379 | ✗ | new_return(ret); | |
| 12380 | } | ||
| 12381 | 3072 | } | |
| 12382 | |||
| 12383 |
2/2✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
|
6156 | for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++) |
| 12384 | { | ||
| 12385 | 6144 | int32_t ret = write_one_ffscript(f, Header, i, comboscripts[i]); | |
| 12386 | |||
| 12387 |
1/2✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
|
6144 | if(ret!=0) |
| 12388 | { | ||
| 12389 | ✗ | new_return(ret); | |
| 12390 | } | ||
| 12391 | 6144 | } | |
| 12392 | |||
| 12393 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(NUMSCRIPTSGENERIC,f)) |
| 12394 | { | ||
| 12395 | ✗ | new_return(2000); | |
| 12396 | } | ||
| 12397 |
2/2✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
|
6156 | for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++) |
| 12398 | { | ||
| 12399 | 6144 | int32_t ret = write_one_ffscript(f, Header, i, genericscripts[i]); | |
| 12400 | |||
| 12401 |
1/2✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
|
6144 | if(ret!=0) |
| 12402 | { | ||
| 12403 | ✗ | new_return(ret); | |
| 12404 | } | ||
| 12405 | 6144 | } | |
| 12406 | |||
| 12407 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(NUMSCRIPTSSUBSCREEN,f)) |
| 12408 | { | ||
| 12409 | ✗ | new_return(2001); | |
| 12410 | } | ||
| 12411 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
|
3084 | for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++) |
| 12412 | { | ||
| 12413 | 3072 | int32_t ret = write_one_ffscript(f, Header, i, subscreenscripts[i]); | |
| 12414 | |||
| 12415 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 12416 | { | ||
| 12417 | ✗ | new_return(ret); | |
| 12418 | } | ||
| 12419 | 3072 | } | |
| 12420 | |||
| 12421 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputl((int32_t)zScript.size(), f)) |
| 12422 | { | ||
| 12423 | ✗ | new_return(2001); | |
| 12424 | } | ||
| 12425 | |||
| 12426 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!pfwrite((void *)zScript.c_str(), (int32_t)zScript.size(), f)) |
| 12427 | { | ||
| 12428 | ✗ | new_return(2002); | |
| 12429 | } | ||
| 12430 | |||
| 12431 | 12 | word numffcbindings=0; | |
| 12432 | |||
| 12433 |
2/2✓ Branch 0 taken 6132 times.
✓ Branch 1 taken 12 times.
|
6144 | for(std::map<int32_t, script_slot_data >::iterator it = ffcmap.begin(); it != ffcmap.end(); it++) |
| 12434 | { | ||
| 12435 |
2/2✓ Branch 0 taken 5984 times.
✓ Branch 1 taken 148 times.
|
6132 | if(it->second.scriptname != "") |
| 12436 | { | ||
| 12437 | 148 | numffcbindings++; | |
| 12438 | 148 | } | |
| 12439 | 6132 | } | |
| 12440 | |||
| 12441 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numffcbindings, f)) |
| 12442 | { | ||
| 12443 | ✗ | new_return(2003); | |
| 12444 | } | ||
| 12445 | |||
| 12446 |
2/2✓ Branch 0 taken 6132 times.
✓ Branch 1 taken 12 times.
|
6144 | for(std::map<int32_t, script_slot_data >::iterator it = ffcmap.begin(); it != ffcmap.end(); it++) |
| 12447 | { | ||
| 12448 |
2/2✓ Branch 0 taken 5984 times.
✓ Branch 1 taken 148 times.
|
6132 | if(it->second.scriptname != "") |
| 12449 | { | ||
| 12450 |
1/2✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
|
148 | if(!p_iputw(it->first,f)) |
| 12451 | { | ||
| 12452 | ✗ | new_return(2004); | |
| 12453 | } | ||
| 12454 | |||
| 12455 |
1/2✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
|
148 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 12456 | { | ||
| 12457 | ✗ | new_return(2005); | |
| 12458 | } | ||
| 12459 | |||
| 12460 |
1/2✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
|
148 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 12461 | { | ||
| 12462 | ✗ | new_return(2006); | |
| 12463 | } | ||
| 12464 | 148 | } | |
| 12465 | 6132 | } | |
| 12466 | |||
| 12467 | 12 | word numglobalbindings=0; | |
| 12468 | |||
| 12469 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12 times.
|
108 | for(std::map<int32_t, script_slot_data >::iterator it = globalmap.begin(); it != globalmap.end(); it++) |
| 12470 | { | ||
| 12471 |
2/2✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
|
96 | if(it->second.scriptname != "") |
| 12472 | { | ||
| 12473 | 22 | numglobalbindings++; | |
| 12474 | 22 | } | |
| 12475 | 96 | } | |
| 12476 | |||
| 12477 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numglobalbindings, f)) |
| 12478 | { | ||
| 12479 | ✗ | new_return(2007); | |
| 12480 | } | ||
| 12481 | |||
| 12482 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12 times.
|
108 | for(std::map<int32_t, script_slot_data >::iterator it = globalmap.begin(); it != globalmap.end(); it++) |
| 12483 | { | ||
| 12484 |
2/2✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
|
96 | if(it->second.scriptname != "") |
| 12485 | { | ||
| 12486 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | if(!p_iputw(it->first,f)) |
| 12487 | { | ||
| 12488 | ✗ | new_return(2008); | |
| 12489 | } | ||
| 12490 | |||
| 12491 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 12492 | { | ||
| 12493 | ✗ | new_return(2009); | |
| 12494 | } | ||
| 12495 | |||
| 12496 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 12497 | { | ||
| 12498 | ✗ | new_return(2010); | |
| 12499 | } | ||
| 12500 | 22 | } | |
| 12501 | 96 | } | |
| 12502 | |||
| 12503 | 12 | word numitembindings=0; | |
| 12504 | |||
| 12505 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = itemmap.begin(); it != itemmap.end(); it++) |
| 12506 | { | ||
| 12507 |
2/2✓ Branch 0 taken 3034 times.
✓ Branch 1 taken 26 times.
|
3060 | if(it->second.scriptname != "") |
| 12508 | { | ||
| 12509 | 26 | numitembindings++; | |
| 12510 | 26 | } | |
| 12511 | 3060 | } | |
| 12512 | |||
| 12513 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numitembindings, f)) |
| 12514 | { | ||
| 12515 | ✗ | new_return(2011); | |
| 12516 | } | ||
| 12517 | |||
| 12518 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = itemmap.begin(); it != itemmap.end(); it++) |
| 12519 | { | ||
| 12520 |
2/2✓ Branch 0 taken 3034 times.
✓ Branch 1 taken 26 times.
|
3060 | if(it->second.scriptname != "") |
| 12521 | { | ||
| 12522 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if(!p_iputw(it->first,f)) |
| 12523 | { | ||
| 12524 | ✗ | new_return(2012); | |
| 12525 | } | ||
| 12526 | |||
| 12527 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 12528 | { | ||
| 12529 | ✗ | new_return(2013); | |
| 12530 | } | ||
| 12531 | |||
| 12532 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 12533 | { | ||
| 12534 | ✗ | new_return(2014); | |
| 12535 | } | ||
| 12536 | 26 | } | |
| 12537 | 3060 | } | |
| 12538 | |||
| 12539 | //new script types | ||
| 12540 | //npc scripts | ||
| 12541 | 12 | word numnpcbindings=0; | |
| 12542 | |||
| 12543 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = npcmap.begin(); it != npcmap.end(); it++) |
| 12544 | { | ||
| 12545 |
1/2✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
|
3060 | if(it->second.scriptname != "") |
| 12546 | { | ||
| 12547 | ✗ | numnpcbindings++; | |
| 12548 | ✗ | } | |
| 12549 | 3060 | } | |
| 12550 | |||
| 12551 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numnpcbindings, f)) |
| 12552 | { | ||
| 12553 | ✗ | new_return(2015); | |
| 12554 | } | ||
| 12555 | |||
| 12556 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = npcmap.begin(); it != npcmap.end(); it++) |
| 12557 | { | ||
| 12558 |
1/2✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
|
3060 | if(it->second.scriptname != "") |
| 12559 | { | ||
| 12560 | ✗ | if(!p_iputw(it->first,f)) | |
| 12561 | { | ||
| 12562 | ✗ | new_return(2016); | |
| 12563 | } | ||
| 12564 | |||
| 12565 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 12566 | { | ||
| 12567 | ✗ | new_return(2017); | |
| 12568 | } | ||
| 12569 | |||
| 12570 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 12571 | { | ||
| 12572 | ✗ | new_return(2018); | |
| 12573 | } | ||
| 12574 | ✗ | } | |
| 12575 | 3060 | } | |
| 12576 | |||
| 12577 | //lweapon | ||
| 12578 | |||
| 12579 | 12 | word numlwpnbindings=0; | |
| 12580 | |||
| 12581 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = lwpnmap.begin(); it != lwpnmap.end(); it++) |
| 12582 | { | ||
| 12583 |
2/2✓ Branch 0 taken 3058 times.
✓ Branch 1 taken 2 times.
|
3060 | if(it->second.scriptname != "") |
| 12584 | { | ||
| 12585 | 2 | numlwpnbindings++; | |
| 12586 | 2 | } | |
| 12587 | 3060 | } | |
| 12588 | |||
| 12589 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numlwpnbindings, f)) |
| 12590 | { | ||
| 12591 | ✗ | new_return(2019); | |
| 12592 | } | ||
| 12593 | |||
| 12594 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = lwpnmap.begin(); it != lwpnmap.end(); it++) |
| 12595 | { | ||
| 12596 |
2/2✓ Branch 0 taken 3058 times.
✓ Branch 1 taken 2 times.
|
3060 | if(it->second.scriptname != "") |
| 12597 | { | ||
| 12598 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(!p_iputw(it->first,f)) |
| 12599 | { | ||
| 12600 | ✗ | new_return(2020); | |
| 12601 | } | ||
| 12602 | |||
| 12603 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 12604 | { | ||
| 12605 | ✗ | new_return(2021); | |
| 12606 | } | ||
| 12607 | |||
| 12608 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 12609 | { | ||
| 12610 | ✗ | new_return(2022); | |
| 12611 | } | ||
| 12612 | 2 | } | |
| 12613 | 3060 | } | |
| 12614 | |||
| 12615 | ////// | ||
| 12616 | |||
| 12617 | //eweapon | ||
| 12618 | |||
| 12619 | |||
| 12620 | 12 | word numewpnbindings=0; | |
| 12621 | |||
| 12622 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = ewpnmap.begin(); it != ewpnmap.end(); it++) |
| 12623 | { | ||
| 12624 |
1/2✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
|
3060 | if(it->second.scriptname != "") |
| 12625 | { | ||
| 12626 | ✗ | numewpnbindings++; | |
| 12627 | ✗ | } | |
| 12628 | 3060 | } | |
| 12629 | |||
| 12630 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numewpnbindings, f)) |
| 12631 | { | ||
| 12632 | ✗ | new_return(2023); | |
| 12633 | } | ||
| 12634 | |||
| 12635 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = ewpnmap.begin(); it != ewpnmap.end(); it++) |
| 12636 | { | ||
| 12637 |
1/2✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
|
3060 | if(it->second.scriptname != "") |
| 12638 | { | ||
| 12639 | ✗ | if(!p_iputw(it->first,f)) | |
| 12640 | { | ||
| 12641 | ✗ | new_return(2024); | |
| 12642 | } | ||
| 12643 | |||
| 12644 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 12645 | { | ||
| 12646 | ✗ | new_return(2025); | |
| 12647 | } | ||
| 12648 | |||
| 12649 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 12650 | { | ||
| 12651 | ✗ | new_return(2026); | |
| 12652 | } | ||
| 12653 | ✗ | } | |
| 12654 | 3060 | } | |
| 12655 | |||
| 12656 | //player scripts | ||
| 12657 | 12 | word numherobindings=0; | |
| 12658 | |||
| 12659 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
|
60 | for(std::map<int32_t, script_slot_data >::iterator it = playermap.begin(); it != playermap.end(); it++) |
| 12660 | { | ||
| 12661 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | if(it->second.scriptname != "") |
| 12662 | { | ||
| 12663 | ✗ | numherobindings++; | |
| 12664 | ✗ | } | |
| 12665 | 48 | } | |
| 12666 | |||
| 12667 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numherobindings, f)) |
| 12668 | { | ||
| 12669 | ✗ | new_return(2027); | |
| 12670 | } | ||
| 12671 | |||
| 12672 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
|
60 | for(std::map<int32_t, script_slot_data >::iterator it = playermap.begin(); it != playermap.end(); it++) |
| 12673 | { | ||
| 12674 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | if(it->second.scriptname != "") |
| 12675 | { | ||
| 12676 | ✗ | if(!p_iputw(it->first,f)) | |
| 12677 | { | ||
| 12678 | ✗ | new_return(2028); | |
| 12679 | } | ||
| 12680 | |||
| 12681 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 12682 | { | ||
| 12683 | ✗ | new_return(2029); | |
| 12684 | } | ||
| 12685 | |||
| 12686 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 12687 | { | ||
| 12688 | ✗ | new_return(2030); | |
| 12689 | } | ||
| 12690 | ✗ | } | |
| 12691 | 48 | } | |
| 12692 | |||
| 12693 | //dmap scripts | ||
| 12694 | 12 | word numdmapbindings=0; | |
| 12695 | |||
| 12696 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = dmapmap.begin(); it != dmapmap.end(); it++) |
| 12697 | { | ||
| 12698 |
2/2✓ Branch 0 taken 3050 times.
✓ Branch 1 taken 10 times.
|
3060 | if(it->second.scriptname != "") |
| 12699 | { | ||
| 12700 | 10 | numdmapbindings++; | |
| 12701 | 10 | } | |
| 12702 | 3060 | } | |
| 12703 | |||
| 12704 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numdmapbindings, f)) |
| 12705 | { | ||
| 12706 | ✗ | new_return(2031); | |
| 12707 | } | ||
| 12708 | |||
| 12709 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = dmapmap.begin(); it != dmapmap.end(); it++) |
| 12710 | { | ||
| 12711 |
2/2✓ Branch 0 taken 3050 times.
✓ Branch 1 taken 10 times.
|
3060 | if(it->second.scriptname != "") |
| 12712 | { | ||
| 12713 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_iputw(it->first,f)) |
| 12714 | { | ||
| 12715 | ✗ | new_return(2032); | |
| 12716 | } | ||
| 12717 | |||
| 12718 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 12719 | { | ||
| 12720 | ✗ | new_return(2033); | |
| 12721 | } | ||
| 12722 | |||
| 12723 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 12724 | { | ||
| 12725 | ✗ | new_return(2034); | |
| 12726 | } | ||
| 12727 | 10 | } | |
| 12728 | 3060 | } | |
| 12729 | |||
| 12730 | //screen scripts | ||
| 12731 | 12 | word numscreenbindings=0; | |
| 12732 | |||
| 12733 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = screenmap.begin(); it != screenmap.end(); it++) |
| 12734 | { | ||
| 12735 |
2/2✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 4 times.
|
3060 | if(it->second.scriptname != "") |
| 12736 | { | ||
| 12737 | 4 | numscreenbindings++; | |
| 12738 | 4 | } | |
| 12739 | 3060 | } | |
| 12740 | |||
| 12741 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numscreenbindings, f)) |
| 12742 | { | ||
| 12743 | ✗ | new_return(2035); | |
| 12744 | } | ||
| 12745 | |||
| 12746 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = screenmap.begin(); it != screenmap.end(); it++) |
| 12747 | { | ||
| 12748 |
2/2✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 4 times.
|
3060 | if(it->second.scriptname != "") |
| 12749 | { | ||
| 12750 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if(!p_iputw(it->first,f)) |
| 12751 | { | ||
| 12752 | ✗ | new_return(2036); | |
| 12753 | } | ||
| 12754 | |||
| 12755 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 12756 | { | ||
| 12757 | ✗ | new_return(2037); | |
| 12758 | } | ||
| 12759 | |||
| 12760 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 12761 | { | ||
| 12762 | ✗ | new_return(2038); | |
| 12763 | } | ||
| 12764 | 4 | } | |
| 12765 | 3060 | } | |
| 12766 | //item sprite scripts | ||
| 12767 | 12 | word numitemspritebindings=0; | |
| 12768 | |||
| 12769 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = itemspritemap.begin(); it != itemspritemap.end(); it++) |
| 12770 | { | ||
| 12771 |
1/2✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
|
3060 | if(it->second.scriptname != "") |
| 12772 | { | ||
| 12773 | ✗ | numitemspritebindings++; | |
| 12774 | ✗ | } | |
| 12775 | 3060 | } | |
| 12776 | |||
| 12777 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numitemspritebindings, f)) |
| 12778 | { | ||
| 12779 | ✗ | new_return(2039); | |
| 12780 | } | ||
| 12781 | |||
| 12782 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = itemspritemap.begin(); it != itemspritemap.end(); it++) |
| 12783 | { | ||
| 12784 |
1/2✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
|
3060 | if(it->second.scriptname != "") |
| 12785 | { | ||
| 12786 | ✗ | if(!p_iputw(it->first,f)) | |
| 12787 | { | ||
| 12788 | ✗ | new_return(2040); | |
| 12789 | } | ||
| 12790 | |||
| 12791 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 12792 | { | ||
| 12793 | ✗ | new_return(2041); | |
| 12794 | } | ||
| 12795 | |||
| 12796 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 12797 | { | ||
| 12798 | ✗ | new_return(2042); | |
| 12799 | } | ||
| 12800 | ✗ | } | |
| 12801 | 3060 | } | |
| 12802 | |||
| 12803 | //combo scripts | ||
| 12804 | 12 | word numcombobindings=0; | |
| 12805 | |||
| 12806 |
2/2✓ Branch 0 taken 6132 times.
✓ Branch 1 taken 12 times.
|
6144 | for(std::map<int32_t, script_slot_data >::iterator it = comboscriptmap.begin(); it != comboscriptmap.end(); it++) |
| 12807 | { | ||
| 12808 |
1/2✓ Branch 0 taken 6132 times.
✗ Branch 1 not taken.
|
6132 | if(it->second.scriptname != "") |
| 12809 | { | ||
| 12810 | ✗ | numcombobindings++; | |
| 12811 | ✗ | } | |
| 12812 | 6132 | } | |
| 12813 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numcombobindings, f)) |
| 12814 | { | ||
| 12815 | ✗ | new_return(2043); | |
| 12816 | } | ||
| 12817 | |||
| 12818 |
2/2✓ Branch 0 taken 6132 times.
✓ Branch 1 taken 12 times.
|
6144 | for(std::map<int32_t, script_slot_data >::iterator it = comboscriptmap.begin(); it != comboscriptmap.end(); it++) |
| 12819 | { | ||
| 12820 |
1/2✓ Branch 0 taken 6132 times.
✗ Branch 1 not taken.
|
6132 | if(it->second.scriptname != "") |
| 12821 | { | ||
| 12822 | ✗ | if(!p_iputw(it->first,f)) | |
| 12823 | { | ||
| 12824 | ✗ | new_return(2044); | |
| 12825 | } | ||
| 12826 | |||
| 12827 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 12828 | { | ||
| 12829 | ✗ | new_return(2045); | |
| 12830 | } | ||
| 12831 | |||
| 12832 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 12833 | { | ||
| 12834 | ✗ | new_return(2046); | |
| 12835 | } | ||
| 12836 | ✗ | } | |
| 12837 | 6132 | } | |
| 12838 | //subscreen scripts | ||
| 12839 | 12 | word numgenericbindings=0; | |
| 12840 | |||
| 12841 |
2/2✓ Branch 0 taken 6132 times.
✓ Branch 1 taken 12 times.
|
6144 | for(auto it = genericmap.begin(); it != genericmap.end(); it++) |
| 12842 | { | ||
| 12843 |
2/2✓ Branch 0 taken 6108 times.
✓ Branch 1 taken 24 times.
|
6132 | if(it->second.scriptname != "") |
| 12844 | { | ||
| 12845 | 24 | numgenericbindings++; | |
| 12846 | 24 | } | |
| 12847 | 6132 | } | |
| 12848 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numgenericbindings, f)) |
| 12849 | { | ||
| 12850 | ✗ | new_return(2043); | |
| 12851 | } | ||
| 12852 | |||
| 12853 |
2/2✓ Branch 0 taken 6132 times.
✓ Branch 1 taken 12 times.
|
6144 | for(auto it = genericmap.begin(); it != genericmap.end(); it++) |
| 12854 | { | ||
| 12855 |
2/2✓ Branch 0 taken 6108 times.
✓ Branch 1 taken 24 times.
|
6132 | if(it->second.scriptname != "") |
| 12856 | { | ||
| 12857 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if(!p_iputw(it->first,f)) |
| 12858 | { | ||
| 12859 | ✗ | new_return(2044); | |
| 12860 | } | ||
| 12861 | |||
| 12862 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 12863 | { | ||
| 12864 | ✗ | new_return(2045); | |
| 12865 | } | ||
| 12866 | |||
| 12867 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 12868 | { | ||
| 12869 | ✗ | new_return(2046); | |
| 12870 | } | ||
| 12871 | 24 | } | |
| 12872 | 6132 | } | |
| 12873 | |||
| 12874 | //generic scripts | ||
| 12875 | 12 | word numsubscreenbindings=0; | |
| 12876 | |||
| 12877 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(auto it = subscreenmap.begin(); it != subscreenmap.end(); it++) |
| 12878 | { | ||
| 12879 |
1/2✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
|
3060 | if(it->second.scriptname != "") |
| 12880 | { | ||
| 12881 | ✗ | numsubscreenbindings++; | |
| 12882 | ✗ | } | |
| 12883 | 3060 | } | |
| 12884 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(!p_iputw(numsubscreenbindings, f)) |
| 12885 | { | ||
| 12886 | ✗ | new_return(2047); | |
| 12887 | } | ||
| 12888 | |||
| 12889 |
2/2✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 12 times.
|
3072 | for(auto it = subscreenmap.begin(); it != subscreenmap.end(); it++) |
| 12890 | { | ||
| 12891 |
1/2✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
|
3060 | if(it->second.scriptname != "") |
| 12892 | { | ||
| 12893 | ✗ | if(!p_iputw(it->first,f)) | |
| 12894 | { | ||
| 12895 | ✗ | new_return(2048); | |
| 12896 | } | ||
| 12897 | |||
| 12898 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 12899 | { | ||
| 12900 | ✗ | new_return(2049); | |
| 12901 | } | ||
| 12902 | |||
| 12903 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 12904 | { | ||
| 12905 | ✗ | new_return(2050); | |
| 12906 | } | ||
| 12907 | ✗ | } | |
| 12908 | 3060 | } | |
| 12909 | |||
| 12910 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
|
12 | if(writecycle==0) |
| 12911 | { | ||
| 12912 | 6 | section_size=writesize; | |
| 12913 | 6 | } | |
| 12914 | 12 | } | |
| 12915 | |||
| 12916 | |||
| 12917 | |||
| 12918 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
6 | if(writesize!=int32_t(section_size) && save_warn) |
| 12919 | { | ||
| 12920 | char ebuf[80]; | ||
| 12921 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 12922 | ✗ | jwin_alert("Error: writeffscript()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 12923 | ✗ | } | |
| 12924 | |||
| 12925 | 6 | new_return(0); | |
| 12926 | //return 0; //this is just here to stomp the compiler from whining. | ||
| 12927 | //the irony is that it causes an "unreachable code" warning. | ||
| 12928 | 9 | } | |
| 12929 | |||
| 12930 | 12 | int32_t write_quest_zasm(PACKFILE *f) | |
| 12931 | { | ||
| 12932 | extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts; | ||
| 12933 | 12 | auto& zasm = zasm_scripts[0]->zasm; | |
| 12934 | 12 | size_t num_commands = zasm.size(); | |
| 12935 | |||
| 12936 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | if(!p_iputl(num_commands,f)) |
| 12937 | ✗ | new_return(1); | |
| 12938 | |||
| 12939 |
2/2✓ Branch 0 taken 338704 times.
✓ Branch 1 taken 12 times.
|
338716 | for(int32_t j=0; j<num_commands; j++) |
| 12940 | { | ||
| 12941 | 338704 | auto& zas = zasm[j]; | |
| 12942 | |||
| 12943 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 338704 times.
|
338704 | if(zas.command==0xFFFF) |
| 12944 | ✗ | continue; | |
| 12945 | else | ||
| 12946 | { | ||
| 12947 |
1/2✓ Branch 0 taken 338704 times.
✗ Branch 1 not taken.
|
338704 | if(!p_iputw(zas.command,f)) |
| 12948 | ✗ | new_return(2); | |
| 12949 | |||
| 12950 |
1/2✓ Branch 0 taken 338704 times.
✗ Branch 1 not taken.
|
338704 | if(!p_iputl(zas.arg1,f)) |
| 12951 | ✗ | new_return(3); | |
| 12952 | |||
| 12953 |
1/2✓ Branch 0 taken 338704 times.
✗ Branch 1 not taken.
|
338704 | if(!p_iputl(zas.arg2,f)) |
| 12954 | ✗ | new_return(4); | |
| 12955 | |||
| 12956 |
1/2✓ Branch 0 taken 338704 times.
✗ Branch 1 not taken.
|
338704 | if(!p_iputl(zas.arg3,f)) |
| 12957 | ✗ | new_return(5); | |
| 12958 | |||
| 12959 | 338704 | uint32_t sz = 0; | |
| 12960 |
2/2✓ Branch 0 taken 338052 times.
✓ Branch 1 taken 652 times.
|
338704 | if(zas.strptr) |
| 12961 | 652 | sz = zas.strptr->size(); | |
| 12962 |
1/2✓ Branch 0 taken 338704 times.
✗ Branch 1 not taken.
|
338704 | if(!p_iputl(sz,f)) |
| 12963 | ✗ | new_return(6); | |
| 12964 |
2/2✓ Branch 0 taken 338058 times.
✓ Branch 1 taken 646 times.
|
338704 | if(sz) |
| 12965 | { | ||
| 12966 | 646 | auto& str = *zas.strptr; | |
| 12967 |
2/2✓ Branch 0 taken 13284 times.
✓ Branch 1 taken 646 times.
|
13930 | for(size_t q = 0; q < sz; ++q) |
| 12968 | { | ||
| 12969 |
1/2✓ Branch 0 taken 13284 times.
✗ Branch 1 not taken.
|
13284 | if(!p_putc(str[q],f)) |
| 12970 | ✗ | new_return(7); | |
| 12971 | 13284 | } | |
| 12972 | 646 | } | |
| 12973 | 338704 | sz = 0; | |
| 12974 |
2/2✓ Branch 0 taken 338596 times.
✓ Branch 1 taken 108 times.
|
338704 | if(zas.vecptr) |
| 12975 | 108 | sz = zas.vecptr->size(); | |
| 12976 |
1/2✓ Branch 0 taken 338704 times.
✗ Branch 1 not taken.
|
338704 | if(!p_iputl(sz,f)) |
| 12977 | ✗ | new_return(8); | |
| 12978 |
2/2✓ Branch 0 taken 338596 times.
✓ Branch 1 taken 108 times.
|
338704 | if(sz) //vector found |
| 12979 | { | ||
| 12980 | 108 | auto& vec = *zas.vecptr; | |
| 12981 |
2/2✓ Branch 0 taken 556 times.
✓ Branch 1 taken 108 times.
|
664 | for(size_t q = 0; q < sz; ++q) |
| 12982 | { | ||
| 12983 |
1/2✓ Branch 0 taken 556 times.
✗ Branch 1 not taken.
|
556 | if(!p_iputl(vec[q],f)) |
| 12984 | ✗ | new_return(9); | |
| 12985 | 556 | } | |
| 12986 | 108 | } | |
| 12987 | } | ||
| 12988 | 338704 | } | |
| 12989 | 12 | return 0; | |
| 12990 | } | ||
| 12991 | |||
| 12992 | 46236 | int32_t write_one_ffscript(PACKFILE *f, zquestheader *, int32_t, script_data *script) | |
| 12993 | { | ||
| 12994 |
2/2✓ Branch 0 taken 46008 times.
✓ Branch 1 taken 228 times.
|
46236 | if (!script->valid()) |
| 12995 | { | ||
| 12996 |
1/2✓ Branch 0 taken 46008 times.
✗ Branch 1 not taken.
|
46008 | if (!p_putc(0, f)) |
| 12997 | ✗ | new_return(-1); | |
| 12998 | 46008 | return 0; | |
| 12999 | } | ||
| 13000 | |||
| 13001 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if (!p_putc(1, f)) |
| 13002 | ✗ | new_return(-1); | |
| 13003 | |||
| 13004 | 228 | zasm_meta const& tmeta = script->meta; | |
| 13005 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_iputw(tmeta.zasm_v,f)) |
| 13006 | ✗ | new_return(1); | |
| 13007 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_iputw(tmeta.meta_v,f)) |
| 13008 | ✗ | new_return(2); | |
| 13009 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_iputw(tmeta.ffscript_v,f)) |
| 13010 | ✗ | new_return(3); | |
| 13011 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_putc((int)tmeta.script_type,f)) |
| 13012 | ✗ | new_return(4); | |
| 13013 | |||
| 13014 |
2/2✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 228 times.
|
2052 | for(int32_t q = 0; q < 8; ++q) |
| 13015 | { | ||
| 13016 |
1/2✓ Branch 0 taken 1824 times.
✗ Branch 1 not taken.
|
1824 | if(!p_putcstr(tmeta.run_idens[q],f)) |
| 13017 | ✗ | new_return(5); | |
| 13018 | 1824 | } | |
| 13019 | |||
| 13020 |
2/2✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 228 times.
|
2052 | for(int32_t q = 0; q < 8; ++q) |
| 13021 |
1/2✓ Branch 0 taken 1824 times.
✗ Branch 1 not taken.
|
1824 | if(!p_putc(tmeta.run_types[q],f)) |
| 13022 | ✗ | new_return(6); | |
| 13023 | |||
| 13024 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_putc(tmeta.flags,f)) |
| 13025 | ✗ | new_return(7); | |
| 13026 | |||
| 13027 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_iputw(tmeta.compiler_v1,f)) |
| 13028 | ✗ | new_return(8); | |
| 13029 | |||
| 13030 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_iputw(tmeta.compiler_v2,f)) |
| 13031 | ✗ | new_return(9); | |
| 13032 | |||
| 13033 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_iputw(tmeta.compiler_v3,f)) |
| 13034 | ✗ | new_return(10); | |
| 13035 | |||
| 13036 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_iputw(tmeta.compiler_v4,f)) |
| 13037 | ✗ | new_return(11); | |
| 13038 | |||
| 13039 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_putcstr(tmeta.script_name,f)) |
| 13040 | ✗ | new_return(12); | |
| 13041 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_putcstr(tmeta.author,f)) |
| 13042 | ✗ | new_return(13); | |
| 13043 |
2/2✓ Branch 0 taken 2280 times.
✓ Branch 1 taken 228 times.
|
2508 | for(auto q = 0; q < 10; ++q) |
| 13044 | { | ||
| 13045 |
1/2✓ Branch 0 taken 2280 times.
✗ Branch 1 not taken.
|
2280 | if(!p_putcstr(tmeta.attributes[q],f)) |
| 13046 | ✗ | new_return(14); | |
| 13047 |
1/2✓ Branch 0 taken 2280 times.
✗ Branch 1 not taken.
|
2280 | if(!p_putwstr(tmeta.attributes_help[q],f)) |
| 13048 | ✗ | new_return(15); | |
| 13049 | 2280 | } | |
| 13050 |
2/2✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 228 times.
|
2052 | for(auto q = 0; q < 8; ++q) |
| 13051 | { | ||
| 13052 |
1/2✓ Branch 0 taken 1824 times.
✗ Branch 1 not taken.
|
1824 | if(!p_putcstr(tmeta.attribytes[q],f)) |
| 13053 | ✗ | new_return(16); | |
| 13054 |
1/2✓ Branch 0 taken 1824 times.
✗ Branch 1 not taken.
|
1824 | if(!p_putwstr(tmeta.attribytes_help[q],f)) |
| 13055 | ✗ | new_return(17); | |
| 13056 | 1824 | } | |
| 13057 |
2/2✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 228 times.
|
2052 | for(auto q = 0; q < 8; ++q) |
| 13058 | { | ||
| 13059 |
1/2✓ Branch 0 taken 1824 times.
✗ Branch 1 not taken.
|
1824 | if(!p_putcstr(tmeta.attrishorts[q],f)) |
| 13060 | ✗ | new_return(18); | |
| 13061 |
1/2✓ Branch 0 taken 1824 times.
✗ Branch 1 not taken.
|
1824 | if(!p_putwstr(tmeta.attrishorts_help[q],f)) |
| 13062 | ✗ | new_return(19); | |
| 13063 | 1824 | } | |
| 13064 |
2/2✓ Branch 0 taken 3648 times.
✓ Branch 1 taken 228 times.
|
3876 | for(auto q = 0; q < 16; ++q) |
| 13065 | { | ||
| 13066 |
1/2✓ Branch 0 taken 3648 times.
✗ Branch 1 not taken.
|
3648 | if(!p_putcstr(tmeta.usrflags[q],f)) |
| 13067 | ✗ | new_return(20); | |
| 13068 |
1/2✓ Branch 0 taken 3648 times.
✗ Branch 1 not taken.
|
3648 | if(!p_putwstr(tmeta.usrflags_help[q],f)) |
| 13069 | ✗ | new_return(21); | |
| 13070 | 3648 | } | |
| 13071 |
2/2✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 228 times.
|
2052 | for(auto q = 0; q < 8; ++q) |
| 13072 | { | ||
| 13073 |
1/2✓ Branch 0 taken 1824 times.
✗ Branch 1 not taken.
|
1824 | if(!p_putcstr(tmeta.initd[q],f)) |
| 13074 | ✗ | new_return(22); | |
| 13075 |
1/2✓ Branch 0 taken 1824 times.
✗ Branch 1 not taken.
|
1824 | if(!p_putwstr(tmeta.initd_help[q],f)) |
| 13076 | ✗ | new_return(23); | |
| 13077 | 1824 | } | |
| 13078 |
2/2✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 228 times.
|
2052 | for(auto q = 0; q < 8; ++q) |
| 13079 | { | ||
| 13080 |
1/2✓ Branch 0 taken 1824 times.
✗ Branch 1 not taken.
|
1824 | if(!p_putc(tmeta.initd_type[q],f)) |
| 13081 | ✗ | new_return(24); | |
| 13082 | 1824 | } | |
| 13083 | |||
| 13084 |
1/2✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
|
228 | if(!p_iputl(script->pc, f)) |
| 13085 | ✗ | new_return(25); | |
| 13086 | |||
| 13087 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
|
228 | if(!p_iputl(script->end_pc, f)) |
| 13088 | ✗ | new_return(26); | |
| 13089 | |||
| 13090 | 228 | return 0; | |
| 13091 | 46236 | } | |
| 13092 | |||
| 13093 | |||
| 13094 | 3 | int32_t writeffscript_old(PACKFILE *f, zquestheader *Header) | |
| 13095 | { | ||
| 13096 | 3 | dword section_id = ID_FFSCRIPT; | |
| 13097 | 3 | dword section_version = 26; | |
| 13098 | 3 | dword section_cversion = 1; | |
| 13099 | 3 | dword section_size = 0; | |
| 13100 | 3 | dword zasmmeta_version = 5; | |
| 13101 | 3 | byte numscripts = 0; | |
| 13102 | 3 | numscripts = numscripts; //to avoid unused variables warnings | |
| 13103 | |||
| 13104 | //section id | ||
| 13105 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if(!p_mputl(section_id,f)) |
| 13106 | { | ||
| 13107 | ✗ | new_return(1); | |
| 13108 | } | ||
| 13109 | |||
| 13110 | //section version info | ||
| 13111 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if(!p_iputw(section_version,f)) |
| 13112 | { | ||
| 13113 | ✗ | new_return(2); | |
| 13114 | } | ||
| 13115 | |||
| 13116 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if(!p_iputw(section_cversion,f)) |
| 13117 | { | ||
| 13118 | ✗ | new_return(3); | |
| 13119 | } | ||
| 13120 | |||
| 13121 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if(!p_iputw(zasmmeta_version,f)) |
| 13122 | { | ||
| 13123 | ✗ | new_return(4); | |
| 13124 | } | ||
| 13125 | |||
| 13126 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
|
9 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 13127 | { | ||
| 13128 | 6 | fake_pack_writing=(writecycle==0); | |
| 13129 | |||
| 13130 | //section size | ||
| 13131 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if(!p_iputl(section_size,f)) |
| 13132 | { | ||
| 13133 | ✗ | new_return(5); | |
| 13134 | } | ||
| 13135 | |||
| 13136 | 6 | writesize=0; | |
| 13137 | |||
| 13138 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 6 times.
|
3078 | for(int32_t i=0; i<NUMSCRIPTFFC; i++) |
| 13139 | { | ||
| 13140 | 3072 | int32_t ret = write_one_ffscript_old(f, Header, i, ffscripts[i]); | |
| 13141 | 3072 | fake_pack_writing=(writecycle==0); | |
| 13142 | |||
| 13143 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 13144 | { | ||
| 13145 | ✗ | new_return(ret); | |
| 13146 | } | ||
| 13147 | 3072 | } | |
| 13148 | |||
| 13149 |
2/2✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
|
1542 | for(int32_t i=0; i<NUMSCRIPTITEM; i++) |
| 13150 | { | ||
| 13151 | 1536 | int32_t ret = write_one_ffscript_old(f, Header, i, itemscripts[i]); | |
| 13152 | 1536 | fake_pack_writing=(writecycle==0); | |
| 13153 | |||
| 13154 |
1/2✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
|
1536 | if(ret!=0) |
| 13155 | { | ||
| 13156 | ✗ | new_return(ret); | |
| 13157 | } | ||
| 13158 | 1536 | } | |
| 13159 | |||
| 13160 |
2/2✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
|
1542 | for(int32_t i=0; i<NUMSCRIPTGUYS; i++) |
| 13161 | { | ||
| 13162 | 1536 | int32_t ret = write_one_ffscript_old(f, Header, i, guyscripts[i]); | |
| 13163 | 1536 | fake_pack_writing=(writecycle==0); | |
| 13164 | |||
| 13165 |
1/2✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
|
1536 | if(ret!=0) |
| 13166 | { | ||
| 13167 | ✗ | new_return(ret); | |
| 13168 | } | ||
| 13169 | 1536 | } | |
| 13170 | |||
| 13171 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | script_data *fake = new script_data(ScriptType::None, 0); |
| 13172 |
2/2✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
|
1542 | for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++) |
| 13173 | { | ||
| 13174 | 1536 | int32_t ret = write_one_ffscript_old(f, Header, i, fake); | |
| 13175 | 1536 | fake_pack_writing=(writecycle==0); | |
| 13176 | |||
| 13177 |
1/2✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
|
1536 | if(ret!=0) |
| 13178 | { | ||
| 13179 | ✗ | new_return(ret); | |
| 13180 | } | ||
| 13181 | 1536 | } | |
| 13182 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | delete fake; |
| 13183 | |||
| 13184 |
2/2✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
|
1542 | for(int32_t i=0; i<NUMSCRIPTSCREEN; i++) |
| 13185 | { | ||
| 13186 | 1536 | int32_t ret = write_one_ffscript_old(f, Header, i, screenscripts[i]); | |
| 13187 | 1536 | fake_pack_writing=(writecycle==0); | |
| 13188 | |||
| 13189 |
1/2✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
|
1536 | if(ret!=0) |
| 13190 | { | ||
| 13191 | ✗ | new_return(ret); | |
| 13192 | } | ||
| 13193 | 1536 | } | |
| 13194 | |||
| 13195 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
|
54 | for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++) |
| 13196 | { | ||
| 13197 | 48 | int32_t ret = write_one_ffscript_old(f, Header, i, globalscripts[i]); | |
| 13198 | 48 | fake_pack_writing=(writecycle==0); | |
| 13199 | |||
| 13200 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | if(ret!=0) |
| 13201 | { | ||
| 13202 | ✗ | new_return(ret); | |
| 13203 | } | ||
| 13204 | 48 | } | |
| 13205 | |||
| 13206 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 6 times.
|
36 | for(int32_t i=0; i<NUMSCRIPTHERO; i++) |
| 13207 | { | ||
| 13208 | 30 | int32_t ret = write_one_ffscript_old(f, Header, i, playerscripts[i]); | |
| 13209 | 30 | fake_pack_writing=(writecycle==0); | |
| 13210 | |||
| 13211 |
1/2✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
|
30 | if(ret!=0) |
| 13212 | { | ||
| 13213 | ✗ | new_return(ret); | |
| 13214 | } | ||
| 13215 | 30 | } | |
| 13216 | |||
| 13217 |
2/2✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
|
1542 | for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++) |
| 13218 | { | ||
| 13219 | 1536 | int32_t ret = write_one_ffscript_old(f, Header, i, lwpnscripts[i]); | |
| 13220 | 1536 | fake_pack_writing=(writecycle==0); | |
| 13221 | |||
| 13222 |
1/2✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
|
1536 | if(ret!=0) |
| 13223 | { | ||
| 13224 | ✗ | new_return(ret); | |
| 13225 | } | ||
| 13226 | 1536 | } | |
| 13227 | |||
| 13228 |
2/2✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
|
1542 | for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++) |
| 13229 | { | ||
| 13230 | 1536 | int32_t ret = write_one_ffscript_old(f, Header, i, ewpnscripts[i]); | |
| 13231 | 1536 | fake_pack_writing=(writecycle==0); | |
| 13232 | |||
| 13233 |
1/2✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
|
1536 | if(ret!=0) |
| 13234 | { | ||
| 13235 | ✗ | new_return(ret); | |
| 13236 | } | ||
| 13237 | 1536 | } | |
| 13238 | |||
| 13239 |
2/2✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
|
1542 | for(int32_t i=0; i<NUMSCRIPTSDMAP; i++) |
| 13240 | { | ||
| 13241 | 1536 | int32_t ret = write_one_ffscript_old(f, Header, i, dmapscripts[i]); | |
| 13242 | 1536 | fake_pack_writing=(writecycle==0); | |
| 13243 | |||
| 13244 |
1/2✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
|
1536 | if(ret!=0) |
| 13245 | { | ||
| 13246 | ✗ | new_return(ret); | |
| 13247 | } | ||
| 13248 | 1536 | } | |
| 13249 | |||
| 13250 |
2/2✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
|
1542 | for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++) |
| 13251 | { | ||
| 13252 | 1536 | int32_t ret = write_one_ffscript_old(f, Header, i, itemspritescripts[i]); | |
| 13253 | 1536 | fake_pack_writing=(writecycle==0); | |
| 13254 | |||
| 13255 |
1/2✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
|
1536 | if(ret!=0) |
| 13256 | { | ||
| 13257 | ✗ | new_return(ret); | |
| 13258 | } | ||
| 13259 | 1536 | } | |
| 13260 | |||
| 13261 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 6 times.
|
3078 | for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++) |
| 13262 | { | ||
| 13263 | 3072 | int32_t ret = write_one_ffscript_old(f, Header, i, comboscripts[i]); | |
| 13264 | 3072 | fake_pack_writing=(writecycle==0); | |
| 13265 | |||
| 13266 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 13267 | { | ||
| 13268 | ✗ | new_return(ret); | |
| 13269 | } | ||
| 13270 | 3072 | } | |
| 13271 | |||
| 13272 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(NUMSCRIPTSGENERIC,f)) |
| 13273 | { | ||
| 13274 | ✗ | new_return(2000); | |
| 13275 | } | ||
| 13276 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 6 times.
|
3078 | for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++) |
| 13277 | { | ||
| 13278 | 3072 | int32_t ret = write_one_ffscript_old(f, Header, i, genericscripts[i]); | |
| 13279 | 3072 | fake_pack_writing=(writecycle==0); | |
| 13280 | |||
| 13281 |
1/2✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
|
3072 | if(ret!=0) |
| 13282 | { | ||
| 13283 | ✗ | new_return(ret); | |
| 13284 | } | ||
| 13285 | 3072 | } | |
| 13286 | |||
| 13287 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(NUMSCRIPTSSUBSCREEN,f)) |
| 13288 | { | ||
| 13289 | ✗ | new_return(2001); | |
| 13290 | } | ||
| 13291 |
2/2✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
|
1542 | for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++) |
| 13292 | { | ||
| 13293 | 1536 | int32_t ret = write_one_ffscript_old(f, Header, i, subscreenscripts[i]); | |
| 13294 | 1536 | fake_pack_writing=(writecycle==0); | |
| 13295 | |||
| 13296 |
1/2✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
|
1536 | if(ret!=0) |
| 13297 | { | ||
| 13298 | ✗ | new_return(ret); | |
| 13299 | } | ||
| 13300 | 1536 | } | |
| 13301 | |||
| 13302 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputl((int32_t)zScript.size(), f)) |
| 13303 | { | ||
| 13304 | ✗ | new_return(2001); | |
| 13305 | } | ||
| 13306 | |||
| 13307 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!pfwrite((void *)zScript.c_str(), (int32_t)zScript.size(), f)) |
| 13308 | { | ||
| 13309 | ✗ | new_return(2002); | |
| 13310 | } | ||
| 13311 | |||
| 13312 | 6 | word numffcbindings=0; | |
| 13313 | |||
| 13314 |
2/2✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = ffcmap.begin(); it != ffcmap.end(); it++) |
| 13315 | { | ||
| 13316 |
2/2✓ Branch 0 taken 2860 times.
✓ Branch 1 taken 206 times.
|
3066 | if(it->second.scriptname != "") |
| 13317 | { | ||
| 13318 | 206 | numffcbindings++; | |
| 13319 | 206 | } | |
| 13320 | 3066 | } | |
| 13321 | |||
| 13322 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numffcbindings, f)) |
| 13323 | { | ||
| 13324 | ✗ | new_return(2003); | |
| 13325 | } | ||
| 13326 | |||
| 13327 |
2/2✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = ffcmap.begin(); it != ffcmap.end(); it++) |
| 13328 | { | ||
| 13329 |
2/2✓ Branch 0 taken 2860 times.
✓ Branch 1 taken 206 times.
|
3066 | if(it->second.scriptname != "") |
| 13330 | { | ||
| 13331 |
1/2✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
|
206 | if(!p_iputw(it->first,f)) |
| 13332 | { | ||
| 13333 | ✗ | new_return(2004); | |
| 13334 | } | ||
| 13335 | |||
| 13336 |
1/2✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
|
206 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 13337 | { | ||
| 13338 | ✗ | new_return(2005); | |
| 13339 | } | ||
| 13340 | |||
| 13341 |
1/2✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
|
206 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 13342 | { | ||
| 13343 | ✗ | new_return(2006); | |
| 13344 | } | ||
| 13345 | 206 | } | |
| 13346 | 3066 | } | |
| 13347 | |||
| 13348 | 6 | word numglobalbindings=0; | |
| 13349 | |||
| 13350 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
|
54 | for(std::map<int32_t, script_slot_data >::iterator it = globalmap.begin(); it != globalmap.end(); it++) |
| 13351 | { | ||
| 13352 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 18 times.
|
48 | if(it->second.scriptname != "") |
| 13353 | { | ||
| 13354 | 18 | numglobalbindings++; | |
| 13355 | 18 | } | |
| 13356 | 48 | } | |
| 13357 | |||
| 13358 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numglobalbindings, f)) |
| 13359 | { | ||
| 13360 | ✗ | new_return(2007); | |
| 13361 | } | ||
| 13362 | |||
| 13363 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
|
54 | for(std::map<int32_t, script_slot_data >::iterator it = globalmap.begin(); it != globalmap.end(); it++) |
| 13364 | { | ||
| 13365 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 18 times.
|
48 | if(it->second.scriptname != "") |
| 13366 | { | ||
| 13367 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(it->first,f)) |
| 13368 | { | ||
| 13369 | ✗ | new_return(2008); | |
| 13370 | } | ||
| 13371 | |||
| 13372 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 13373 | { | ||
| 13374 | ✗ | new_return(2009); | |
| 13375 | } | ||
| 13376 | |||
| 13377 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 13378 | { | ||
| 13379 | ✗ | new_return(2010); | |
| 13380 | } | ||
| 13381 | 18 | } | |
| 13382 | 48 | } | |
| 13383 | |||
| 13384 | 6 | word numitembindings=0; | |
| 13385 | |||
| 13386 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = itemmap.begin(); it != itemmap.end(); it++) |
| 13387 | { | ||
| 13388 |
2/2✓ Branch 0 taken 1512 times.
✓ Branch 1 taken 18 times.
|
1530 | if(it->second.scriptname != "") |
| 13389 | { | ||
| 13390 | 18 | numitembindings++; | |
| 13391 | 18 | } | |
| 13392 | 1530 | } | |
| 13393 | |||
| 13394 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numitembindings, f)) |
| 13395 | { | ||
| 13396 | ✗ | new_return(2011); | |
| 13397 | } | ||
| 13398 | |||
| 13399 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = itemmap.begin(); it != itemmap.end(); it++) |
| 13400 | { | ||
| 13401 |
2/2✓ Branch 0 taken 1512 times.
✓ Branch 1 taken 18 times.
|
1530 | if(it->second.scriptname != "") |
| 13402 | { | ||
| 13403 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(it->first,f)) |
| 13404 | { | ||
| 13405 | ✗ | new_return(2012); | |
| 13406 | } | ||
| 13407 | |||
| 13408 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 13409 | { | ||
| 13410 | ✗ | new_return(2013); | |
| 13411 | } | ||
| 13412 | |||
| 13413 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 13414 | { | ||
| 13415 | ✗ | new_return(2014); | |
| 13416 | } | ||
| 13417 | 18 | } | |
| 13418 | 1530 | } | |
| 13419 | |||
| 13420 | //new script types | ||
| 13421 | //npc scripts | ||
| 13422 | 6 | word numnpcbindings=0; | |
| 13423 | |||
| 13424 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = npcmap.begin(); it != npcmap.end(); it++) |
| 13425 | { | ||
| 13426 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13427 | { | ||
| 13428 | ✗ | numnpcbindings++; | |
| 13429 | ✗ | } | |
| 13430 | 1530 | } | |
| 13431 | |||
| 13432 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numnpcbindings, f)) |
| 13433 | { | ||
| 13434 | ✗ | new_return(2015); | |
| 13435 | } | ||
| 13436 | |||
| 13437 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = npcmap.begin(); it != npcmap.end(); it++) |
| 13438 | { | ||
| 13439 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13440 | { | ||
| 13441 | ✗ | if(!p_iputw(it->first,f)) | |
| 13442 | { | ||
| 13443 | ✗ | new_return(2016); | |
| 13444 | } | ||
| 13445 | |||
| 13446 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 13447 | { | ||
| 13448 | ✗ | new_return(2017); | |
| 13449 | } | ||
| 13450 | |||
| 13451 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 13452 | { | ||
| 13453 | ✗ | new_return(2018); | |
| 13454 | } | ||
| 13455 | ✗ | } | |
| 13456 | 1530 | } | |
| 13457 | |||
| 13458 | //lweapon | ||
| 13459 | |||
| 13460 | 6 | word numlwpnbindings=0; | |
| 13461 | |||
| 13462 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = lwpnmap.begin(); it != lwpnmap.end(); it++) |
| 13463 | { | ||
| 13464 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13465 | { | ||
| 13466 | ✗ | numlwpnbindings++; | |
| 13467 | ✗ | } | |
| 13468 | 1530 | } | |
| 13469 | |||
| 13470 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numlwpnbindings, f)) |
| 13471 | { | ||
| 13472 | ✗ | new_return(2019); | |
| 13473 | } | ||
| 13474 | |||
| 13475 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = lwpnmap.begin(); it != lwpnmap.end(); it++) |
| 13476 | { | ||
| 13477 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13478 | { | ||
| 13479 | ✗ | if(!p_iputw(it->first,f)) | |
| 13480 | { | ||
| 13481 | ✗ | new_return(2020); | |
| 13482 | } | ||
| 13483 | |||
| 13484 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 13485 | { | ||
| 13486 | ✗ | new_return(2021); | |
| 13487 | } | ||
| 13488 | |||
| 13489 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 13490 | { | ||
| 13491 | ✗ | new_return(2022); | |
| 13492 | } | ||
| 13493 | ✗ | } | |
| 13494 | 1530 | } | |
| 13495 | |||
| 13496 | ////// | ||
| 13497 | |||
| 13498 | //eweapon | ||
| 13499 | |||
| 13500 | |||
| 13501 | 6 | word numewpnbindings=0; | |
| 13502 | |||
| 13503 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = ewpnmap.begin(); it != ewpnmap.end(); it++) |
| 13504 | { | ||
| 13505 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13506 | { | ||
| 13507 | ✗ | numewpnbindings++; | |
| 13508 | ✗ | } | |
| 13509 | 1530 | } | |
| 13510 | |||
| 13511 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numewpnbindings, f)) |
| 13512 | { | ||
| 13513 | ✗ | new_return(2023); | |
| 13514 | } | ||
| 13515 | |||
| 13516 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = ewpnmap.begin(); it != ewpnmap.end(); it++) |
| 13517 | { | ||
| 13518 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13519 | { | ||
| 13520 | ✗ | if(!p_iputw(it->first,f)) | |
| 13521 | { | ||
| 13522 | ✗ | new_return(2024); | |
| 13523 | } | ||
| 13524 | |||
| 13525 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 13526 | { | ||
| 13527 | ✗ | new_return(2025); | |
| 13528 | } | ||
| 13529 | |||
| 13530 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 13531 | { | ||
| 13532 | ✗ | new_return(2026); | |
| 13533 | } | ||
| 13534 | ✗ | } | |
| 13535 | 1530 | } | |
| 13536 | |||
| 13537 | //player scripts | ||
| 13538 | 6 | word numherobindings=0; | |
| 13539 | |||
| 13540 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
|
30 | for(std::map<int32_t, script_slot_data >::iterator it = playermap.begin(); it != playermap.end(); it++) |
| 13541 | { | ||
| 13542 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2 times.
|
24 | if(it->second.scriptname != "") |
| 13543 | { | ||
| 13544 | 2 | numherobindings++; | |
| 13545 | 2 | } | |
| 13546 | 24 | } | |
| 13547 | |||
| 13548 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numherobindings, f)) |
| 13549 | { | ||
| 13550 | ✗ | new_return(2027); | |
| 13551 | } | ||
| 13552 | |||
| 13553 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
|
30 | for(std::map<int32_t, script_slot_data >::iterator it = playermap.begin(); it != playermap.end(); it++) |
| 13554 | { | ||
| 13555 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2 times.
|
24 | if(it->second.scriptname != "") |
| 13556 | { | ||
| 13557 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(!p_iputw(it->first,f)) |
| 13558 | { | ||
| 13559 | ✗ | new_return(2028); | |
| 13560 | } | ||
| 13561 | |||
| 13562 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 13563 | { | ||
| 13564 | ✗ | new_return(2029); | |
| 13565 | } | ||
| 13566 | |||
| 13567 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 13568 | { | ||
| 13569 | ✗ | new_return(2030); | |
| 13570 | } | ||
| 13571 | 2 | } | |
| 13572 | 24 | } | |
| 13573 | |||
| 13574 | //dmap scripts | ||
| 13575 | 6 | word numdmapbindings=0; | |
| 13576 | |||
| 13577 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = dmapmap.begin(); it != dmapmap.end(); it++) |
| 13578 | { | ||
| 13579 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13580 | { | ||
| 13581 | ✗ | numdmapbindings++; | |
| 13582 | ✗ | } | |
| 13583 | 1530 | } | |
| 13584 | |||
| 13585 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numdmapbindings, f)) |
| 13586 | { | ||
| 13587 | ✗ | new_return(2031); | |
| 13588 | } | ||
| 13589 | |||
| 13590 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = dmapmap.begin(); it != dmapmap.end(); it++) |
| 13591 | { | ||
| 13592 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13593 | { | ||
| 13594 | ✗ | if(!p_iputw(it->first,f)) | |
| 13595 | { | ||
| 13596 | ✗ | new_return(2032); | |
| 13597 | } | ||
| 13598 | |||
| 13599 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 13600 | { | ||
| 13601 | ✗ | new_return(2033); | |
| 13602 | } | ||
| 13603 | |||
| 13604 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 13605 | { | ||
| 13606 | ✗ | new_return(2034); | |
| 13607 | } | ||
| 13608 | ✗ | } | |
| 13609 | 1530 | } | |
| 13610 | |||
| 13611 | //screen scripts | ||
| 13612 | 6 | word numscreenbindings=0; | |
| 13613 | |||
| 13614 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = screenmap.begin(); it != screenmap.end(); it++) |
| 13615 | { | ||
| 13616 |
2/2✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 14 times.
|
1530 | if(it->second.scriptname != "") |
| 13617 | { | ||
| 13618 | 14 | numscreenbindings++; | |
| 13619 | 14 | } | |
| 13620 | 1530 | } | |
| 13621 | |||
| 13622 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numscreenbindings, f)) |
| 13623 | { | ||
| 13624 | ✗ | new_return(2035); | |
| 13625 | } | ||
| 13626 | |||
| 13627 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = screenmap.begin(); it != screenmap.end(); it++) |
| 13628 | { | ||
| 13629 |
2/2✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 14 times.
|
1530 | if(it->second.scriptname != "") |
| 13630 | { | ||
| 13631 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if(!p_iputw(it->first,f)) |
| 13632 | { | ||
| 13633 | ✗ | new_return(2036); | |
| 13634 | } | ||
| 13635 | |||
| 13636 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) |
| 13637 | { | ||
| 13638 | ✗ | new_return(2037); | |
| 13639 | } | ||
| 13640 | |||
| 13641 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) |
| 13642 | { | ||
| 13643 | ✗ | new_return(2038); | |
| 13644 | } | ||
| 13645 | 14 | } | |
| 13646 | 1530 | } | |
| 13647 | //item sprite scripts | ||
| 13648 | 6 | word numitemspritebindings=0; | |
| 13649 | |||
| 13650 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = itemspritemap.begin(); it != itemspritemap.end(); it++) |
| 13651 | { | ||
| 13652 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13653 | { | ||
| 13654 | ✗ | numitemspritebindings++; | |
| 13655 | ✗ | } | |
| 13656 | 1530 | } | |
| 13657 | |||
| 13658 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numitemspritebindings, f)) |
| 13659 | { | ||
| 13660 | ✗ | new_return(2039); | |
| 13661 | } | ||
| 13662 | |||
| 13663 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(std::map<int32_t, script_slot_data >::iterator it = itemspritemap.begin(); it != itemspritemap.end(); it++) |
| 13664 | { | ||
| 13665 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13666 | { | ||
| 13667 | ✗ | if(!p_iputw(it->first,f)) | |
| 13668 | { | ||
| 13669 | ✗ | new_return(2040); | |
| 13670 | } | ||
| 13671 | |||
| 13672 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 13673 | { | ||
| 13674 | ✗ | new_return(2041); | |
| 13675 | } | ||
| 13676 | |||
| 13677 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 13678 | { | ||
| 13679 | ✗ | new_return(2042); | |
| 13680 | } | ||
| 13681 | ✗ | } | |
| 13682 | 1530 | } | |
| 13683 | |||
| 13684 | //combo scripts | ||
| 13685 | 6 | word numcombobindings=0; | |
| 13686 | |||
| 13687 |
2/2✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = comboscriptmap.begin(); it != comboscriptmap.end(); it++) |
| 13688 | { | ||
| 13689 |
1/2✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
|
3066 | if(it->second.scriptname != "") |
| 13690 | { | ||
| 13691 | ✗ | numcombobindings++; | |
| 13692 | ✗ | } | |
| 13693 | 3066 | } | |
| 13694 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numcombobindings, f)) |
| 13695 | { | ||
| 13696 | ✗ | new_return(2043); | |
| 13697 | } | ||
| 13698 | |||
| 13699 |
2/2✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
|
3072 | for(std::map<int32_t, script_slot_data >::iterator it = comboscriptmap.begin(); it != comboscriptmap.end(); it++) |
| 13700 | { | ||
| 13701 |
1/2✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
|
3066 | if(it->second.scriptname != "") |
| 13702 | { | ||
| 13703 | ✗ | if(!p_iputw(it->first,f)) | |
| 13704 | { | ||
| 13705 | ✗ | new_return(2044); | |
| 13706 | } | ||
| 13707 | |||
| 13708 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 13709 | { | ||
| 13710 | ✗ | new_return(2045); | |
| 13711 | } | ||
| 13712 | |||
| 13713 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 13714 | { | ||
| 13715 | ✗ | new_return(2046); | |
| 13716 | } | ||
| 13717 | ✗ | } | |
| 13718 | 3066 | } | |
| 13719 | //subscreen scripts | ||
| 13720 | 6 | word numgenericbindings=0; | |
| 13721 | |||
| 13722 |
2/2✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
|
3072 | for(auto it = genericmap.begin(); it != genericmap.end(); it++) |
| 13723 | { | ||
| 13724 |
1/2✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
|
3066 | if(it->second.scriptname != "") |
| 13725 | { | ||
| 13726 | ✗ | numgenericbindings++; | |
| 13727 | ✗ | } | |
| 13728 | 3066 | } | |
| 13729 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numgenericbindings, f)) |
| 13730 | { | ||
| 13731 | ✗ | new_return(2043); | |
| 13732 | } | ||
| 13733 | |||
| 13734 |
2/2✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
|
3072 | for(auto it = genericmap.begin(); it != genericmap.end(); it++) |
| 13735 | { | ||
| 13736 |
1/2✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
|
3066 | if(it->second.scriptname != "") |
| 13737 | { | ||
| 13738 | ✗ | if(!p_iputw(it->first,f)) | |
| 13739 | { | ||
| 13740 | ✗ | new_return(2044); | |
| 13741 | } | ||
| 13742 | |||
| 13743 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 13744 | { | ||
| 13745 | ✗ | new_return(2045); | |
| 13746 | } | ||
| 13747 | |||
| 13748 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 13749 | { | ||
| 13750 | ✗ | new_return(2046); | |
| 13751 | } | ||
| 13752 | ✗ | } | |
| 13753 | 3066 | } | |
| 13754 | |||
| 13755 | //generic scripts | ||
| 13756 | 6 | word numsubscreenbindings=0; | |
| 13757 | |||
| 13758 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(auto it = subscreenmap.begin(); it != subscreenmap.end(); it++) |
| 13759 | { | ||
| 13760 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13761 | { | ||
| 13762 | ✗ | numsubscreenbindings++; | |
| 13763 | ✗ | } | |
| 13764 | 1530 | } | |
| 13765 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(!p_iputw(numsubscreenbindings, f)) |
| 13766 | { | ||
| 13767 | ✗ | new_return(2047); | |
| 13768 | } | ||
| 13769 | |||
| 13770 |
2/2✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
|
1536 | for(auto it = subscreenmap.begin(); it != subscreenmap.end(); it++) |
| 13771 | { | ||
| 13772 |
1/2✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
|
1530 | if(it->second.scriptname != "") |
| 13773 | { | ||
| 13774 | ✗ | if(!p_iputw(it->first,f)) | |
| 13775 | { | ||
| 13776 | ✗ | new_return(2048); | |
| 13777 | } | ||
| 13778 | |||
| 13779 | ✗ | if(!p_iputl((int32_t)it->second.scriptname.size(), f)) | |
| 13780 | { | ||
| 13781 | ✗ | new_return(2049); | |
| 13782 | } | ||
| 13783 | |||
| 13784 | ✗ | if(!pfwrite((void *)it->second.scriptname.c_str(), (int32_t)it->second.scriptname.size(),f)) | |
| 13785 | { | ||
| 13786 | ✗ | new_return(2050); | |
| 13787 | } | ||
| 13788 | ✗ | } | |
| 13789 | 1530 | } | |
| 13790 | |||
| 13791 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
|
6 | if(writecycle==0) |
| 13792 | { | ||
| 13793 | 3 | section_size=writesize; | |
| 13794 | 3 | } | |
| 13795 | 6 | } | |
| 13796 | |||
| 13797 | |||
| 13798 | |||
| 13799 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3 | if(writesize!=int32_t(section_size) && save_warn) |
| 13800 | { | ||
| 13801 | char ebuf[80]; | ||
| 13802 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 13803 | ✗ | jwin_alert("Error: writeffscript()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 13804 | ✗ | } | |
| 13805 | |||
| 13806 | 3 | new_return(0); | |
| 13807 | //return 0; //this is just here to stomp the compiler from whining. | ||
| 13808 | //the irony is that it causes an "unreachable code" warning. | ||
| 13809 | 3 | } | |
| 13810 | |||
| 13811 | 23118 | int32_t write_one_ffscript_old(PACKFILE *f, zquestheader *Header, int32_t i, script_data *script) | |
| 13812 | { | ||
| 13813 | //these are here to bypass compiler warnings about unused arguments | ||
| 13814 | 23118 | Header=Header; | |
| 13815 | 23118 | i=i; | |
| 13816 | |||
| 13817 |
2/2✓ Branch 0 taken 11830 times.
✓ Branch 1 taken 11288 times.
|
23118 | size_t num_commands = script->zasm_script ? script->zasm_script->size : 0; |
| 13818 | |||
| 13819 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_iputl(num_commands,f)) |
| 13820 | { | ||
| 13821 | ✗ | new_return(6); | |
| 13822 | } | ||
| 13823 | |||
| 13824 | //Metadata | ||
| 13825 | 23118 | zasm_meta const& tmeta = script->meta; | |
| 13826 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_iputw(tmeta.zasm_v,f)) |
| 13827 | { | ||
| 13828 | ✗ | new_return(7); | |
| 13829 | } | ||
| 13830 | |||
| 13831 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_iputw(tmeta.meta_v,f)) |
| 13832 | { | ||
| 13833 | ✗ | new_return(8); | |
| 13834 | } | ||
| 13835 | |||
| 13836 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_iputw(tmeta.ffscript_v,f)) |
| 13837 | { | ||
| 13838 | ✗ | new_return(9); | |
| 13839 | } | ||
| 13840 | |||
| 13841 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_putc((int)tmeta.script_type,f)) |
| 13842 | { | ||
| 13843 | ✗ | new_return(10); | |
| 13844 | } | ||
| 13845 | |||
| 13846 |
2/2✓ Branch 0 taken 184944 times.
✓ Branch 1 taken 23118 times.
|
208062 | for(int32_t q = 0; q < 8; ++q) |
| 13847 | { | ||
| 13848 |
1/2✓ Branch 0 taken 184944 times.
✗ Branch 1 not taken.
|
184944 | if(!p_putcstr(tmeta.run_idens[q],f)) |
| 13849 | ✗ | new_return(11); | |
| 13850 | 184944 | } | |
| 13851 | |||
| 13852 |
2/2✓ Branch 0 taken 184944 times.
✓ Branch 1 taken 23118 times.
|
208062 | for(int32_t q = 0; q < 8; ++q) |
| 13853 | { | ||
| 13854 |
1/2✓ Branch 0 taken 184944 times.
✗ Branch 1 not taken.
|
184944 | if(!p_putc(tmeta.run_types[q],f)) |
| 13855 | { | ||
| 13856 | ✗ | new_return(12); | |
| 13857 | } | ||
| 13858 | 184944 | } | |
| 13859 | |||
| 13860 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_putc(tmeta.flags,f)) |
| 13861 | { | ||
| 13862 | ✗ | new_return(13); | |
| 13863 | } | ||
| 13864 | |||
| 13865 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_iputw(tmeta.compiler_v1,f)) |
| 13866 | { | ||
| 13867 | ✗ | new_return(14); | |
| 13868 | } | ||
| 13869 | |||
| 13870 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_iputw(tmeta.compiler_v2,f)) |
| 13871 | { | ||
| 13872 | ✗ | new_return(15); | |
| 13873 | } | ||
| 13874 | |||
| 13875 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_iputw(tmeta.compiler_v3,f)) |
| 13876 | { | ||
| 13877 | ✗ | new_return(16); | |
| 13878 | } | ||
| 13879 | |||
| 13880 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_iputw(tmeta.compiler_v4,f)) |
| 13881 | { | ||
| 13882 | ✗ | new_return(17); | |
| 13883 | } | ||
| 13884 | |||
| 13885 |
1/2✓ Branch 0 taken 23118 times.
✗ Branch 1 not taken.
|
23118 | if(!p_putcstr(tmeta.script_name,f)) |
| 13886 | ✗ | new_return(18); | |
| 13887 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23118 times.
|
23118 | if(!p_putcstr(tmeta.author,f)) |
| 13888 | ✗ | new_return(19); | |
| 13889 |
2/2✓ Branch 0 taken 231180 times.
✓ Branch 1 taken 23118 times.
|
254298 | for(auto q = 0; q < 10; ++q) |
| 13890 | { | ||
| 13891 |
1/2✓ Branch 0 taken 231180 times.
✗ Branch 1 not taken.
|
231180 | if(!p_putcstr(tmeta.attributes[q],f)) |
| 13892 | ✗ | new_return(27); | |
| 13893 |
1/2✓ Branch 0 taken 231180 times.
✗ Branch 1 not taken.
|
231180 | if(!p_putwstr(tmeta.attributes_help[q],f)) |
| 13894 | ✗ | new_return(28); | |
| 13895 | 231180 | } | |
| 13896 |
2/2✓ Branch 0 taken 184944 times.
✓ Branch 1 taken 23118 times.
|
208062 | for(auto q = 0; q < 8; ++q) |
| 13897 | { | ||
| 13898 |
1/2✓ Branch 0 taken 184944 times.
✗ Branch 1 not taken.
|
184944 | if(!p_putcstr(tmeta.attribytes[q],f)) |
| 13899 | ✗ | new_return(29); | |
| 13900 |
1/2✓ Branch 0 taken 184944 times.
✗ Branch 1 not taken.
|
184944 | if(!p_putwstr(tmeta.attribytes_help[q],f)) |
| 13901 | ✗ | new_return(30); | |
| 13902 | 184944 | } | |
| 13903 |
2/2✓ Branch 0 taken 184944 times.
✓ Branch 1 taken 23118 times.
|
208062 | for(auto q = 0; q < 8; ++q) |
| 13904 | { | ||
| 13905 |
1/2✓ Branch 0 taken 184944 times.
✗ Branch 1 not taken.
|
184944 | if(!p_putcstr(tmeta.attrishorts[q],f)) |
| 13906 | ✗ | new_return(31); | |
| 13907 |
1/2✓ Branch 0 taken 184944 times.
✗ Branch 1 not taken.
|
184944 | if(!p_putwstr(tmeta.attrishorts_help[q],f)) |
| 13908 | ✗ | new_return(32); | |
| 13909 | 184944 | } | |
| 13910 |
2/2✓ Branch 0 taken 369888 times.
✓ Branch 1 taken 23118 times.
|
393006 | for(auto q = 0; q < 16; ++q) |
| 13911 | { | ||
| 13912 |
1/2✓ Branch 0 taken 369888 times.
✗ Branch 1 not taken.
|
369888 | if(!p_putcstr(tmeta.usrflags[q],f)) |
| 13913 | ✗ | new_return(33); | |
| 13914 |
1/2✓ Branch 0 taken 369888 times.
✗ Branch 1 not taken.
|
369888 | if(!p_putwstr(tmeta.usrflags_help[q],f)) |
| 13915 | ✗ | new_return(34); | |
| 13916 | 369888 | } | |
| 13917 |
2/2✓ Branch 0 taken 184944 times.
✓ Branch 1 taken 23118 times.
|
208062 | for(auto q = 0; q < 8; ++q) |
| 13918 | { | ||
| 13919 |
1/2✓ Branch 0 taken 184944 times.
✗ Branch 1 not taken.
|
184944 | if(!p_putcstr(tmeta.initd[q],f)) |
| 13920 | ✗ | new_return(35); | |
| 13921 |
1/2✓ Branch 0 taken 184944 times.
✗ Branch 1 not taken.
|
184944 | if(!p_putwstr(tmeta.initd_help[q],f)) |
| 13922 | ✗ | new_return(36); | |
| 13923 | 184944 | } | |
| 13924 |
2/2✓ Branch 0 taken 184944 times.
✓ Branch 1 taken 23118 times.
|
208062 | for(auto q = 0; q < 8; ++q) |
| 13925 | { | ||
| 13926 |
1/2✓ Branch 0 taken 184944 times.
✗ Branch 1 not taken.
|
184944 | if(!p_putc(tmeta.initd_type[q],f)) |
| 13927 | ✗ | new_return(37); | |
| 13928 | 184944 | } | |
| 13929 | |||
| 13930 |
2/2✓ Branch 0 taken 11288 times.
✓ Branch 1 taken 2056888 times.
|
2068176 | for(int32_t j=0; j<num_commands; j++) |
| 13931 | { | ||
| 13932 | 2056888 | auto& zas = script->zasm_script->zasm[j]; | |
| 13933 |
1/2✓ Branch 0 taken 2056888 times.
✗ Branch 1 not taken.
|
2056888 | if(!p_iputw(zas.command,f)) |
| 13934 | { | ||
| 13935 | ✗ | new_return(20); | |
| 13936 | } | ||
| 13937 | |||
| 13938 |
2/2✓ Branch 0 taken 2045058 times.
✓ Branch 1 taken 11830 times.
|
2056888 | if(zas.command==0xFFFF) |
| 13939 | { | ||
| 13940 | 11830 | break; | |
| 13941 | } | ||
| 13942 | else | ||
| 13943 | { | ||
| 13944 |
1/2✓ Branch 0 taken 2045058 times.
✗ Branch 1 not taken.
|
2045058 | if(!p_iputl(zas.arg1,f)) |
| 13945 | { | ||
| 13946 | ✗ | new_return(21); | |
| 13947 | } | ||
| 13948 | |||
| 13949 |
1/2✓ Branch 0 taken 2045058 times.
✗ Branch 1 not taken.
|
2045058 | if(!p_iputl(zas.arg2,f)) |
| 13950 | { | ||
| 13951 | ✗ | new_return(22); | |
| 13952 | } | ||
| 13953 | |||
| 13954 |
1/2✓ Branch 0 taken 2045058 times.
✗ Branch 1 not taken.
|
2045058 | if(!p_iputl(zas.arg3,f)) |
| 13955 | { | ||
| 13956 | ✗ | new_return(23); | |
| 13957 | } | ||
| 13958 | |||
| 13959 | 2045058 | uint32_t sz = 0; | |
| 13960 |
2/2✓ Branch 0 taken 2340 times.
✓ Branch 1 taken 2042718 times.
|
2045058 | if(zas.strptr) |
| 13961 | 2340 | sz = zas.strptr->size(); | |
| 13962 |
1/2✓ Branch 0 taken 2045058 times.
✗ Branch 1 not taken.
|
2045058 | if(!p_iputl(sz,f)) |
| 13963 | { | ||
| 13964 | ✗ | new_return(23); | |
| 13965 | } | ||
| 13966 |
2/2✓ Branch 0 taken 2042718 times.
✓ Branch 1 taken 2340 times.
|
2045058 | if(sz) |
| 13967 | { | ||
| 13968 | 2340 | auto& str = *zas.strptr; | |
| 13969 |
2/2✓ Branch 0 taken 214720 times.
✓ Branch 1 taken 2340 times.
|
217060 | for(size_t q = 0; q < sz; ++q) |
| 13970 | { | ||
| 13971 |
1/2✓ Branch 0 taken 214720 times.
✗ Branch 1 not taken.
|
214720 | if(!p_putc(str[q],f)) |
| 13972 | { | ||
| 13973 | ✗ | new_return(24); | |
| 13974 | } | ||
| 13975 | 214720 | } | |
| 13976 | 2340 | } | |
| 13977 | 2045058 | sz = 0; | |
| 13978 |
2/2✓ Branch 0 taken 2045036 times.
✓ Branch 1 taken 22 times.
|
2045058 | if(zas.vecptr) |
| 13979 | 22 | sz = zas.vecptr->size(); | |
| 13980 |
1/2✓ Branch 0 taken 2045058 times.
✗ Branch 1 not taken.
|
2045058 | if(!p_iputl(sz,f)) |
| 13981 | { | ||
| 13982 | ✗ | new_return(25); | |
| 13983 | } | ||
| 13984 |
2/2✓ Branch 0 taken 2045036 times.
✓ Branch 1 taken 22 times.
|
2045058 | if(sz) //vector found |
| 13985 | { | ||
| 13986 | 22 | auto& vec = *zas.vecptr; | |
| 13987 |
2/2✓ Branch 0 taken 352 times.
✓ Branch 1 taken 22 times.
|
374 | for(size_t q = 0; q < sz; ++q) |
| 13988 | { | ||
| 13989 |
1/2✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
|
352 | if(!p_iputl(vec[q],f)) |
| 13990 | { | ||
| 13991 | ✗ | new_return(26); | |
| 13992 | } | ||
| 13993 | 352 | } | |
| 13994 | 22 | } | |
| 13995 | } | ||
| 13996 | 2045058 | } | |
| 13997 | |||
| 13998 | 23118 | new_return(0); | |
| 13999 | } | ||
| 14000 | |||
| 14001 | extern SAMPLE customsfxdata[WAV_COUNT]; | ||
| 14002 | extern uint8_t customsfxflag[WAV_COUNT>>3]; | ||
| 14003 | |||
| 14004 | 9 | int32_t writesfx(PACKFILE *f, zquestheader *Header) | |
| 14005 | { | ||
| 14006 | //these are here to bypass compiler warnings about unused arguments | ||
| 14007 | 9 | Header=Header; | |
| 14008 | |||
| 14009 | 9 | dword section_id=ID_SFX; | |
| 14010 | 9 | dword section_version=V_SFX; | |
| 14011 | 9 | dword section_size=0; | |
| 14012 | |||
| 14013 | //section id | ||
| 14014 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 14015 | { | ||
| 14016 | ✗ | new_return(1); | |
| 14017 | } | ||
| 14018 | |||
| 14019 | //section version info | ||
| 14020 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 14021 | { | ||
| 14022 | ✗ | new_return(2); | |
| 14023 | } | ||
| 14024 | |||
| 14025 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 14026 | { | ||
| 14027 | ✗ | new_return(3); | |
| 14028 | } | ||
| 14029 | |||
| 14030 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 14031 | { | ||
| 14032 | 18 | fake_pack_writing=(writecycle==0); | |
| 14033 | |||
| 14034 | //section size | ||
| 14035 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 14036 | { | ||
| 14037 | ✗ | new_return(4); | |
| 14038 | } | ||
| 14039 | |||
| 14040 | 18 | writesize=0; | |
| 14041 | |||
| 14042 |
2/2✓ Branch 0 taken 576 times.
✓ Branch 1 taken 18 times.
|
594 | for(int32_t i=0; i<WAV_COUNT>>3; i++) |
| 14043 | { | ||
| 14044 |
1/2✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
|
576 | if(!p_putc(customsfxflag[i],f)) |
| 14045 | { | ||
| 14046 | ✗ | new_return(5); | |
| 14047 | } | ||
| 14048 | 576 | } | |
| 14049 | |||
| 14050 |
2/2✓ Branch 0 taken 4590 times.
✓ Branch 1 taken 18 times.
|
4608 | for(int32_t i=1; i<WAV_COUNT; i++) |
| 14051 | { | ||
| 14052 |
2/2✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 3330 times.
|
4590 | if(get_bit(customsfxflag, i-1) == 0) |
| 14053 | 3330 | continue; | |
| 14054 | |||
| 14055 |
1/2✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
|
1260 | if(!pfwrite(sfx_string[i], 36, f)) |
| 14056 | { | ||
| 14057 | ✗ | new_return(5); | |
| 14058 | } | ||
| 14059 | 1260 | } | |
| 14060 | |||
| 14061 |
2/2✓ Branch 0 taken 4590 times.
✓ Branch 1 taken 18 times.
|
4608 | for(int32_t i=1; i<WAV_COUNT; i++) |
| 14062 | { | ||
| 14063 |
2/2✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 3330 times.
|
4590 | if(get_bit(customsfxflag, i-1) == 0) |
| 14064 | 3330 | continue; | |
| 14065 | |||
| 14066 |
1/2✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
|
1260 | if(!p_iputl(customsfxdata[i].bits,f)) |
| 14067 | { | ||
| 14068 | ✗ | new_return(5); | |
| 14069 | } | ||
| 14070 | |||
| 14071 |
1/2✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
|
1260 | if(!p_iputl(customsfxdata[i].stereo,f)) |
| 14072 | { | ||
| 14073 | ✗ | new_return(6); | |
| 14074 | } | ||
| 14075 | |||
| 14076 |
1/2✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
|
1260 | if(!p_iputl(customsfxdata[i].freq,f)) |
| 14077 | { | ||
| 14078 | ✗ | new_return(7); | |
| 14079 | } | ||
| 14080 | |||
| 14081 |
1/2✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
|
1260 | if(!p_iputl(customsfxdata[i].priority,f)) |
| 14082 | { | ||
| 14083 | ✗ | new_return(8); | |
| 14084 | } | ||
| 14085 | |||
| 14086 |
1/2✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
|
1260 | if(!p_iputl(customsfxdata[i].len,f)) |
| 14087 | { | ||
| 14088 | ✗ | new_return(9); | |
| 14089 | } | ||
| 14090 | |||
| 14091 |
1/2✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
|
1260 | if(!p_iputl(customsfxdata[i].loop_start,f)) |
| 14092 | { | ||
| 14093 | ✗ | new_return(10); | |
| 14094 | } | ||
| 14095 | |||
| 14096 |
1/2✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
|
1260 | if(!p_iputl(customsfxdata[i].loop_end,f)) |
| 14097 | { | ||
| 14098 | ✗ | new_return(11); | |
| 14099 | } | ||
| 14100 | |||
| 14101 |
1/2✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
|
1260 | if(!p_iputl(customsfxdata[i].param,f)) |
| 14102 | { | ||
| 14103 | ✗ | new_return(12); | |
| 14104 | } | ||
| 14105 | |||
| 14106 | //de-endianfy the data | ||
| 14107 | 1260 | int32_t wordstowrite = (customsfxdata[i].bits==8?1:2)*(customsfxdata[i].stereo==0?1:2)*customsfxdata[i].len/sizeof(word); | |
| 14108 | |||
| 14109 |
2/2✓ Branch 0 taken 28596352 times.
✓ Branch 1 taken 1260 times.
|
28597612 | for(int32_t j=0; j<wordstowrite; j++) |
| 14110 | { | ||
| 14111 |
1/2✓ Branch 0 taken 28596352 times.
✗ Branch 1 not taken.
|
28596352 | if(!p_iputw(((word *)customsfxdata[i].data)[j],f)) |
| 14112 | { | ||
| 14113 | ✗ | new_return(13); | |
| 14114 | } | ||
| 14115 | 28596352 | } | |
| 14116 | 1260 | } | |
| 14117 | |||
| 14118 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 14119 | { | ||
| 14120 | 9 | section_size=writesize; | |
| 14121 | 9 | } | |
| 14122 | 18 | } | |
| 14123 | |||
| 14124 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 14125 | { | ||
| 14126 | char ebuf[80]; | ||
| 14127 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 14128 | ✗ | jwin_alert("Error: writesfx()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 14129 | ✗ | } | |
| 14130 | |||
| 14131 | 9 | new_return(0); | |
| 14132 | } | ||
| 14133 | |||
| 14134 | 9 | int32_t writeinitdata(PACKFILE *f, zquestheader *) | |
| 14135 | { | ||
| 14136 | 9 | dword section_id=ID_INITDATA; | |
| 14137 | 9 | dword section_version=V_INITDATA; | |
| 14138 | 9 | dword section_size = 0; | |
| 14139 | |||
| 14140 | 9 | zinit.last_map=Map.getCurrMap(); | |
| 14141 | 9 | zinit.last_screen=Map.getCurrScr(); | |
| 14142 | 9 | zinit.normalize(); | |
| 14143 | |||
| 14144 | //section id | ||
| 14145 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 14146 | { | ||
| 14147 | ✗ | new_return(1); | |
| 14148 | } | ||
| 14149 | |||
| 14150 | //section version info | ||
| 14151 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 14152 | { | ||
| 14153 | ✗ | new_return(2); | |
| 14154 | } | ||
| 14155 | |||
| 14156 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 14157 | { | ||
| 14158 | ✗ | new_return(3); | |
| 14159 | } | ||
| 14160 | |||
| 14161 | //TODO | ||
| 14162 | |||
| 14163 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 14164 | { | ||
| 14165 | 18 | fake_pack_writing=(writecycle==0); | |
| 14166 | |||
| 14167 | //section size | ||
| 14168 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 14169 | ✗ | new_return(4); | |
| 14170 | |||
| 14171 | 18 | writesize=0; | |
| 14172 | |||
| 14173 |
2/2✓ Branch 0 taken 576 times.
✓ Branch 1 taken 18 times.
|
594 | for(int q = 0; q < MAXITEMS/8; ++q) |
| 14174 |
1/2✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
|
576 | if(!p_putc(zinit.items[q], f)) |
| 14175 | ✗ | new_return(5); | |
| 14176 |
2/2✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 18 times.
|
1170 | for(int q = 0; q < MAXLEVELS/8; ++q) |
| 14177 | { | ||
| 14178 |
1/2✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
|
1152 | if(!p_putc(zinit.map[q], f)) |
| 14179 | ✗ | new_return(6); | |
| 14180 |
1/2✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
|
1152 | if(!p_putc(zinit.compass[q], f)) |
| 14181 | ✗ | new_return(7); | |
| 14182 |
1/2✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
|
1152 | if(!p_putc(zinit.boss_key[q], f)) |
| 14183 | ✗ | new_return(8); | |
| 14184 |
1/2✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
|
1152 | if(!p_putc(zinit.mcguffin[q], f)) |
| 14185 | ✗ | new_return(9); | |
| 14186 | 1152 | } | |
| 14187 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putbvec(zinit.level_keys, f)) |
| 14188 | ✗ | new_return(10); | |
| 14189 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(MAX_COUNTERS,f)) |
| 14190 | ✗ | new_return(11); | |
| 14191 |
2/2✓ Branch 0 taken 1926 times.
✓ Branch 1 taken 18 times.
|
1944 | for(int q = 0; q < MAX_COUNTERS; ++q) |
| 14192 |
1/2✓ Branch 0 taken 1926 times.
✗ Branch 1 not taken.
|
1926 | if(!p_iputw(zinit.counter[q],f)) |
| 14193 | ✗ | new_return(12); | |
| 14194 |
2/2✓ Branch 0 taken 1926 times.
✓ Branch 1 taken 18 times.
|
1944 | for(int q = 0; q < MAX_COUNTERS; ++q) |
| 14195 |
1/2✓ Branch 0 taken 1926 times.
✗ Branch 1 not taken.
|
1926 | if(!p_iputw(zinit.mcounter[q],f)) |
| 14196 | ✗ | new_return(13); | |
| 14197 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.bomb_ratio,f)) |
| 14198 | ✗ | new_return(14); | |
| 14199 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.hcp,f)) |
| 14200 | ✗ | new_return(15); | |
| 14201 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.hcp_per_hc,f)) |
| 14202 | ✗ | new_return(16); | |
| 14203 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(zinit.cont_heart,f)) |
| 14204 | ✗ | new_return(17); | |
| 14205 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.hp_per_heart,f)) |
| 14206 | ✗ | new_return(18); | |
| 14207 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.magic_per_block,f)) |
| 14208 | ✗ | new_return(19); | |
| 14209 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.hero_damage_multiplier,f)) |
| 14210 | ✗ | new_return(20); | |
| 14211 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.ene_damage_multiplier,f)) |
| 14212 | ✗ | new_return(21); | |
| 14213 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.dither_type,f)) |
| 14214 | ✗ | new_return(22); | |
| 14215 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.dither_arg,f)) |
| 14216 | ✗ | new_return(23); | |
| 14217 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.dither_percent,f)) |
| 14218 | ✗ | new_return(24); | |
| 14219 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.def_lightrad,f)) |
| 14220 | ✗ | new_return(25); | |
| 14221 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.transdark_percent,f)) |
| 14222 | ✗ | new_return(26); | |
| 14223 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.darkcol,f)) |
| 14224 | ✗ | new_return(27); | |
| 14225 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.ss_grid_x,f)) |
| 14226 | ✗ | new_return(28); | |
| 14227 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.ss_grid_y,f)) |
| 14228 | ✗ | new_return(29); | |
| 14229 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.ss_grid_xofs,f)) |
| 14230 | ✗ | new_return(30); | |
| 14231 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.ss_grid_yofs,f)) |
| 14232 | ✗ | new_return(31); | |
| 14233 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.ss_grid_color,f)) |
| 14234 | ✗ | new_return(32); | |
| 14235 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.ss_bbox_1_color,f)) |
| 14236 | ✗ | new_return(33); | |
| 14237 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.ss_bbox_2_color,f)) |
| 14238 | ✗ | new_return(34); | |
| 14239 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.ss_flags,f)) |
| 14240 | ✗ | new_return(35); | |
| 14241 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putbitstr(zinit.flags,f)) |
| 14242 | ✗ | new_return(36); | |
| 14243 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.last_map,f)) |
| 14244 | ✗ | new_return(37); | |
| 14245 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.last_screen,f)) |
| 14246 | ✗ | new_return(38); | |
| 14247 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.msg_more_x,f)) |
| 14248 | ✗ | new_return(39); | |
| 14249 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.msg_more_y,f)) |
| 14250 | ✗ | new_return(40); | |
| 14251 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.msg_more_is_offset,f)) |
| 14252 | ✗ | new_return(41); | |
| 14253 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.msg_speed,f)) |
| 14254 | ✗ | new_return(42); | |
| 14255 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.gravity,f)) |
| 14256 | ✗ | new_return(43); | |
| 14257 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.swimgravity,f)) |
| 14258 | ✗ | new_return(44); | |
| 14259 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(zinit.terminalv,f)) |
| 14260 | ✗ | new_return(45); | |
| 14261 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.hero_swim_speed,f)) |
| 14262 | ✗ | new_return(46); | |
| 14263 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.hero_swim_mult,f)) |
| 14264 | ✗ | new_return(47); | |
| 14265 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.hero_swim_div,f)) |
| 14266 | ✗ | new_return(48); | |
| 14267 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(zinit.heroSideswimUpStep,f)) |
| 14268 | ✗ | new_return(49); | |
| 14269 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(zinit.heroSideswimSideStep,f)) |
| 14270 | ✗ | new_return(50); | |
| 14271 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(zinit.heroSideswimDownStep,f)) |
| 14272 | ✗ | new_return(51); | |
| 14273 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.exitWaterJump,f)) |
| 14274 | ✗ | new_return(52); | |
| 14275 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(zinit.heroStep,f)) |
| 14276 | ✗ | new_return(53); | |
| 14277 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.heroAnimationStyle,f)) |
| 14278 | ✗ | new_return(54); | |
| 14279 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.jump_hero_layer_threshold,f)) |
| 14280 | ✗ | new_return(55); | |
| 14281 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(zinit.bunny_ltm,f)) |
| 14282 | ✗ | new_return(56); | |
| 14283 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(zinit.start_dmap,f)) |
| 14284 | ✗ | new_return(57); | |
| 14285 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(zinit.subscrSpeed,f)) |
| 14286 | ✗ | new_return(58); | |
| 14287 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.switchhookstyle,f)) |
| 14288 | ✗ | new_return(59); | |
| 14289 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putc(zinit.magicdrainrate,f)) |
| 14290 | ✗ | new_return(60); | |
| 14291 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputzf(zinit.shove_offset,f)) |
| 14292 | ✗ | new_return(61); | |
| 14293 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putbitstr(zinit.gen_doscript, f)) |
| 14294 | ✗ | new_return(62); | |
| 14295 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putbmap(zinit.gen_exitState, f)) |
| 14296 | ✗ | new_return(63); | |
| 14297 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putbmap(zinit.gen_reloadState, f)) |
| 14298 | ✗ | new_return(64); | |
| 14299 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putbmap(zinit.gen_initd, f)) |
| 14300 | ✗ | new_return(65); | |
| 14301 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putbmap(zinit.gen_eventstate, f)) |
| 14302 | ✗ | new_return(66); | |
| 14303 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putbmap(zinit.gen_data, f)) |
| 14304 | ✗ | new_return(67); | |
| 14305 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_putbmap(zinit.screen_data, f)) |
| 14306 | ✗ | new_return(68); | |
| 14307 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (!p_putc(zinit.spriteflickerspeed, f)) |
| 14308 | ✗ | new_return(69); | |
| 14309 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (!p_putc(zinit.spriteflickercolor, f)) |
| 14310 | ✗ | new_return(70); | |
| 14311 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (!p_putc(zinit.spriteflickertransp, f)) |
| 14312 | ✗ | new_return(71); | |
| 14313 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (!p_iputzf(zinit.air_drag, f)) |
| 14314 | ✗ | new_return(72); | |
| 14315 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (!p_iputw(zinit.light_wave_rate, f)) |
| 14316 | ✗ | new_return(73); | |
| 14317 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (!p_iputw(zinit.light_wave_size, f)) |
| 14318 | ✗ | new_return(74); | |
| 14319 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (!p_putc(zinit.region_mapping, f)) |
| 14320 | ✗ | new_return(75); | |
| 14321 | |||
| 14322 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 14323 | { | ||
| 14324 | 9 | section_size=writesize; | |
| 14325 | 9 | } | |
| 14326 | 18 | } | |
| 14327 | |||
| 14328 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 14329 | { | ||
| 14330 | char ebuf[80]; | ||
| 14331 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 14332 | ✗ | jwin_alert("Error: writeinitdata()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 14333 | ✗ | } | |
| 14334 | |||
| 14335 | 9 | new_return(0); | |
| 14336 | } | ||
| 14337 | |||
| 14338 | 9 | int32_t writeitemdropsets(PACKFILE *f, zquestheader *Header) | |
| 14339 | { | ||
| 14340 | //these are here to bypass compiler warnings about unused arguments | ||
| 14341 | 9 | Header=Header; | |
| 14342 | |||
| 14343 | 9 | dword section_id=ID_ITEMDROPSETS; | |
| 14344 | 9 | dword section_version=V_ITEMDROPSETS; | |
| 14345 | // dword section_size=0; | ||
| 14346 | 9 | dword section_size = 0; | |
| 14347 | 9 | word num_item_drop_sets=count_item_drop_sets(); | |
| 14348 | |||
| 14349 | //section id | ||
| 14350 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 14351 | { | ||
| 14352 | ✗ | new_return(1); | |
| 14353 | } | ||
| 14354 | |||
| 14355 | //section version info | ||
| 14356 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 14357 | { | ||
| 14358 | ✗ | new_return(2); | |
| 14359 | } | ||
| 14360 | |||
| 14361 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 14362 | { | ||
| 14363 | ✗ | new_return(3); | |
| 14364 | } | ||
| 14365 | |||
| 14366 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 14367 | { | ||
| 14368 | 18 | fake_pack_writing=(writecycle==0); | |
| 14369 | |||
| 14370 | //section size | ||
| 14371 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 14372 | { | ||
| 14373 | ✗ | new_return(4); | |
| 14374 | } | ||
| 14375 | |||
| 14376 | 18 | writesize=0; | |
| 14377 | |||
| 14378 | //finally... section data | ||
| 14379 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(num_item_drop_sets,f)) |
| 14380 | { | ||
| 14381 | ✗ | new_return(5); | |
| 14382 | } | ||
| 14383 | |||
| 14384 |
2/2✓ Branch 0 taken 236 times.
✓ Branch 1 taken 18 times.
|
254 | for(int32_t i=0; i<num_item_drop_sets; i++) |
| 14385 | { | ||
| 14386 |
1/2✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
|
236 | if(!pfwrite(item_drop_sets[i].name, sizeof(item_drop_sets[i].name)-1, f)) |
| 14387 | { | ||
| 14388 | ✗ | new_return(6); | |
| 14389 | } | ||
| 14390 | |||
| 14391 |
2/2✓ Branch 0 taken 2360 times.
✓ Branch 1 taken 236 times.
|
2596 | for(int32_t j=0; j<10; ++j) |
| 14392 | { | ||
| 14393 |
1/2✓ Branch 0 taken 2360 times.
✗ Branch 1 not taken.
|
2360 | if(!p_iputw(item_drop_sets[i].item[j],f)) |
| 14394 | { | ||
| 14395 | ✗ | new_return(7); | |
| 14396 | } | ||
| 14397 | 2360 | } | |
| 14398 | |||
| 14399 |
2/2✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 236 times.
|
2832 | for(int32_t j=0; j<11; ++j) |
| 14400 | { | ||
| 14401 |
1/2✓ Branch 0 taken 2596 times.
✗ Branch 1 not taken.
|
2596 | if(!p_iputw(item_drop_sets[i].chance[j],f)) |
| 14402 | { | ||
| 14403 | ✗ | new_return(8); | |
| 14404 | } | ||
| 14405 | 2596 | } | |
| 14406 | 236 | } | |
| 14407 | |||
| 14408 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 14409 | { | ||
| 14410 | 9 | section_size=writesize; | |
| 14411 | 9 | } | |
| 14412 | 18 | } | |
| 14413 | |||
| 14414 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 14415 | { | ||
| 14416 | char ebuf[80]; | ||
| 14417 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 14418 | ✗ | jwin_alert("Error: writeitemdropsets()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 14419 | ✗ | } | |
| 14420 | |||
| 14421 | 9 | new_return(0); | |
| 14422 | } | ||
| 14423 | |||
| 14424 | 9 | int32_t writefavorites(PACKFILE *f, zquestheader*) | |
| 14425 | { | ||
| 14426 | 9 | dword section_id=ID_FAVORITES; | |
| 14427 | 9 | dword section_version=V_FAVORITES; | |
| 14428 | 9 | dword section_size = 0; | |
| 14429 | |||
| 14430 | //section id | ||
| 14431 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_mputl(section_id,f)) |
| 14432 | { | ||
| 14433 | ✗ | new_return(1); | |
| 14434 | } | ||
| 14435 | |||
| 14436 | //section version info | ||
| 14437 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!p_iputw(section_version,f)) |
| 14438 | { | ||
| 14439 | ✗ | new_return(2); | |
| 14440 | } | ||
| 14441 | |||
| 14442 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(!write_deprecated_section_cversion(section_version,f)) |
| 14443 | { | ||
| 14444 | ✗ | new_return(3); | |
| 14445 | } | ||
| 14446 | |||
| 14447 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
|
27 | for(int32_t writecycle=0; writecycle<2; ++writecycle) |
| 14448 | { | ||
| 14449 | 18 | fake_pack_writing=(writecycle==0); | |
| 14450 | |||
| 14451 | //section size | ||
| 14452 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputl(section_size,f)) |
| 14453 | ✗ | new_return(4); | |
| 14454 | |||
| 14455 | 18 | writesize=0; | |
| 14456 | |||
| 14457 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(FAVORITECOMBO_PER_ROW,f)) |
| 14458 | ✗ | new_return(16); | |
| 14459 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(FAVORITECOMBO_PER_PAGE,f)) // Just in case pages get resized again |
| 14460 | ✗ | new_return(17); | |
| 14461 | |||
| 14462 | 18 | word favcmb_cnt = 0; | |
| 14463 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 22234 times.
|
22238 | for(int q = MAXFAVORITECOMBOS-1; q >= 0; --q) |
| 14464 |
2/2✓ Branch 0 taken 22220 times.
✓ Branch 1 taken 14 times.
|
22234 | if(favorite_combos[q] != -1) |
| 14465 | { | ||
| 14466 | 14 | favcmb_cnt = q+1; | |
| 14467 | 14 | break; | |
| 14468 | } | ||
| 14469 | |||
| 14470 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(favcmb_cnt,f)) // This'll probably never change, huh? |
| 14471 | ✗ | new_return(5); | |
| 14472 | |||
| 14473 |
2/2✓ Branch 0 taken 460 times.
✓ Branch 1 taken 18 times.
|
478 | for(int i=0; i<favcmb_cnt; ++i) |
| 14474 | { | ||
| 14475 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if (!p_putc(favorite_combo_modes[i], f)) |
| 14476 | ✗ | new_return(6); | |
| 14477 |
1/2✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
|
460 | if (!p_iputl(favorite_combos[i], f)) |
| 14478 | ✗ | new_return(7); | |
| 14479 | 460 | } | |
| 14480 | |||
| 14481 | |||
| 14482 | 18 | word max_combo_cols = MAX_COMBO_COLS; | |
| 14483 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(max_combo_cols,f)) |
| 14484 | ✗ | new_return(9); | |
| 14485 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
|
90 | for(int q = 0; q < max_combo_cols; ++q) |
| 14486 | { | ||
| 14487 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(First[q],f)) |
| 14488 | ✗ | new_return(10); | |
| 14489 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(combo_alistpos[q],f)) |
| 14490 | ✗ | new_return(11); | |
| 14491 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if(!p_iputl(combo_pool_listpos[q],f)) |
| 14492 | ✗ | new_return(12); | |
| 14493 | 72 | } | |
| 14494 | 18 | word max_mappages = MAX_MAPPAGE_BTNS; | |
| 14495 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if(!p_iputw(max_mappages,f)) |
| 14496 | ✗ | new_return(13); | |
| 14497 |
2/2✓ Branch 0 taken 162 times.
✓ Branch 1 taken 18 times.
|
180 | for(int q = 0; q < max_mappages; ++q) |
| 14498 | { | ||
| 14499 |
1/2✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
|
162 | if(!p_iputl(map_page[q].map,f)) |
| 14500 | ✗ | new_return(14); | |
| 14501 |
1/2✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
|
162 | if(!p_iputl(map_page[q].screen,f)) |
| 14502 | ✗ | new_return(15); | |
| 14503 | 162 | } | |
| 14504 | |||
| 14505 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
|
18 | if(writecycle==0) |
| 14506 | { | ||
| 14507 | 9 | section_size=writesize; | |
| 14508 | 9 | } | |
| 14509 | 18 | } | |
| 14510 | |||
| 14511 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
9 | if(writesize!=int32_t(section_size) && save_warn) |
| 14512 | { | ||
| 14513 | char ebuf[80]; | ||
| 14514 | ✗ | sprintf(ebuf, "%d != %d", writesize, int32_t(section_size)); | |
| 14515 | ✗ | jwin_alert("Error: writefavorites()","writesize != section_size",ebuf,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont)); | |
| 14516 | ✗ | } | |
| 14517 | |||
| 14518 | 9 | new_return(0); | |
| 14519 | } | ||
| 14520 | |||
| 14521 | 9 | static int32_t _save_unencoded_quest_int(const char *filename, bool compressed, const char *afname) | |
| 14522 | { | ||
| 14523 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!afname) afname = filename; |
| 14524 | 9 | reset_combo_animations(); | |
| 14525 | 9 | reset_combo_animations2(); | |
| 14526 | 9 | strcpy(header.id_str,QH_NEWIDSTR); | |
| 14527 | 9 | header.zelda_version = ZELDA_VERSION; | |
| 14528 | 9 | header.internal = INTERNAL_VERSION; | |
| 14529 | 9 | header.data_flags[ZQ_TILES] = true; | |
| 14530 | 9 | header.data_flags[ZQ_CHEATS2] = 1; | |
| 14531 | 9 | header.build=VERSION_BUILD; | |
| 14532 | |||
| 14533 |
2/2✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 9 times.
|
2277 | for(int32_t i=0; i<MAXCUSTOMMIDIS; i++) |
| 14534 | { | ||
| 14535 | 2268 | set_bit(midi_flags,i,int32_t(customtunes[i].data!=NULL)); | |
| 14536 | 2268 | } | |
| 14537 | |||
| 14538 | char zinfofilename[2048]; | ||
| 14539 | 9 | replace_extension(zinfofilename, afname, "zinfo", 2047); | |
| 14540 | |||
| 14541 | 9 | box_start(1, "Saving Quest", get_zc_font(font_lfont), font, true); | |
| 14542 | 9 | box_out("Saving Quest..."); | |
| 14543 | 9 | box_eol(); | |
| 14544 | 9 | box_eol(); | |
| 14545 | |||
| 14546 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | std::string tmp_filename = util::create_temp_file_path(filename); |
| 14547 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | PACKFILE *f = pack_fopen_password(tmp_filename.c_str(),compressed?F_WRITE_PACKED:F_WRITE, ""); |
| 14548 | |||
| 14549 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!f) |
| 14550 | ✗ | return 1; | |
| 14551 | |||
| 14552 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Header..."); |
| 14553 | |||
| 14554 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | if(writeheader(f,&header)!=0) |
| 14555 | ✗ | return 2; | |
| 14556 | |||
| 14557 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14558 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14559 | |||
| 14560 | |||
| 14561 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(header.external_zinfo) |
| 14562 | { | ||
| 14563 | ✗ | PACKFILE *inf = pack_fopen_password(zinfofilename, F_WRITE, ""); | |
| 14564 | |||
| 14565 | ✗ | box_out("Writing ZInfo..."); | |
| 14566 | ✗ | if(inf) | |
| 14567 | { | ||
| 14568 | ✗ | if(writezinfo(inf,ZI)!=0) | |
| 14569 | ✗ | return 2; | |
| 14570 | |||
| 14571 | ✗ | pack_fclose(inf); | |
| 14572 | ✗ | box_out("okay."); | |
| 14573 | ✗ | } | |
| 14574 | ✗ | else box_out(" ...file failure"); | |
| 14575 | ✗ | box_eol(); | |
| 14576 | ✗ | } | |
| 14577 | else | ||
| 14578 | { | ||
| 14579 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing ZInfo..."); |
| 14580 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writezinfo(f,ZI)!=0) |
| 14581 | ✗ | return 2; | |
| 14582 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14583 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14584 | } | ||
| 14585 | |||
| 14586 | |||
| 14587 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Rules..."); |
| 14588 | |||
| 14589 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writerules(f,&header)!=0) |
| 14590 | ✗ | return 3; | |
| 14591 | |||
| 14592 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14593 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14594 | |||
| 14595 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Strings..."); |
| 14596 | |||
| 14597 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writestrings(f, ZELDA_VERSION, VERSION_BUILD, 0, MAXMSGS)!=0) |
| 14598 | ✗ | return 4; | |
| 14599 | |||
| 14600 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14601 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14602 | |||
| 14603 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Doors..."); |
| 14604 | |||
| 14605 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writedoorcombosets(f,&header)!=0) |
| 14606 | ✗ | return 5; | |
| 14607 | |||
| 14608 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14609 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14610 | |||
| 14611 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing DMaps..."); |
| 14612 | |||
| 14613 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writedmaps(f,header.zelda_version,header.build,0,MAXDMAPS)!=0) |
| 14614 | ✗ | return 6; | |
| 14615 | |||
| 14616 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14617 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14618 | |||
| 14619 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing &QMisc. Data..."); |
| 14620 | |||
| 14621 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writemisc(f,&header)!=0) |
| 14622 | ✗ | return 7; | |
| 14623 | |||
| 14624 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14625 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14626 | |||
| 14627 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing &QMisc. Colors..."); |
| 14628 | |||
| 14629 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | if(writemisccolors(f,&header)!=0) |
| 14630 | ✗ | return 8; | |
| 14631 | |||
| 14632 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14633 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14634 | |||
| 14635 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Game Icons..."); |
| 14636 | |||
| 14637 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writegameicons(f,&header)!=0) |
| 14638 | ✗ | return 9; | |
| 14639 | |||
| 14640 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14641 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14642 | |||
| 14643 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Items..."); |
| 14644 | |||
| 14645 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writeitems(f,&header)!=0) |
| 14646 | ✗ | return 10; | |
| 14647 | |||
| 14648 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14649 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14650 | |||
| 14651 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Weapons..."); |
| 14652 | |||
| 14653 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | if(writeweapons(f,&header)!=0) |
| 14654 | ✗ | return 11; | |
| 14655 | |||
| 14656 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14657 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14658 | |||
| 14659 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Maps..."); |
| 14660 | |||
| 14661 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writemaps(f,&header)!=0) |
| 14662 | ✗ | return 12; | |
| 14663 | |||
| 14664 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14665 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14666 | |||
| 14667 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Combos..."); |
| 14668 | |||
| 14669 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | if(writecombos(f,header.zelda_version,header.build,0,MAXCOMBOS)!=0) |
| 14670 | ✗ | return 13; | |
| 14671 | |||
| 14672 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14673 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14674 | |||
| 14675 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Combo Aliases..."); |
| 14676 | |||
| 14677 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writecomboaliases(f,header.zelda_version,header.build)!=0) |
| 14678 | ✗ | return 14; | |
| 14679 | |||
| 14680 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14681 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14682 | |||
| 14683 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Color Data..."); |
| 14684 | |||
| 14685 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writecolordata(f,header.zelda_version,header.build,0,newerpdTOTAL)!=0) |
| 14686 | ✗ | return 15; | |
| 14687 | |||
| 14688 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14689 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14690 | |||
| 14691 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Tiles..."); |
| 14692 | |||
| 14693 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writetiles(f,header.zelda_version,header.build,0,NEWMAXTILES)!=0) |
| 14694 | ✗ | return 16; | |
| 14695 | |||
| 14696 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14697 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14698 | |||
| 14699 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing MIDIs..."); |
| 14700 | |||
| 14701 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | if(writemidis(f)!=0) |
| 14702 | ✗ | return 17; | |
| 14703 | |||
| 14704 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14705 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14706 | |||
| 14707 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Cheat Codes..."); |
| 14708 | |||
| 14709 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | if(writecheats(f,&header)!=0) |
| 14710 | ✗ | return 18; | |
| 14711 | |||
| 14712 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14713 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14714 | |||
| 14715 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Init. Data..."); |
| 14716 | |||
| 14717 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writeinitdata(f,&header)!=0) |
| 14718 | ✗ | return 19; | |
| 14719 | |||
| 14720 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14721 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14722 | |||
| 14723 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Custom Guy Data..."); |
| 14724 | |||
| 14725 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writeguys(f,&header)!=0) |
| 14726 | ✗ | return 20; | |
| 14727 | |||
| 14728 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14729 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14730 | |||
| 14731 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Custom Hero Sprite Data..."); |
| 14732 | |||
| 14733 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writeherosprites(f,&header)!=0) |
| 14734 | ✗ | return 21; | |
| 14735 | |||
| 14736 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14737 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14738 | |||
| 14739 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Custom Subscreen Data..."); |
| 14740 | |||
| 14741 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writesubscreens(f,&header)!=0) |
| 14742 | ✗ | return 22; | |
| 14743 | |||
| 14744 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14745 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14746 | |||
| 14747 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing FF Script Data..."); |
| 14748 | |||
| 14749 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writeffscript(f,&header)!=0) |
| 14750 | ✗ | return 23; | |
| 14751 | |||
| 14752 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14753 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14754 | |||
| 14755 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing SFX Data..."); |
| 14756 | |||
| 14757 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writesfx(f,&header)!=0) |
| 14758 | ✗ | return 24; | |
| 14759 | |||
| 14760 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14761 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14762 | |||
| 14763 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Item Drop Sets..."); |
| 14764 | |||
| 14765 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | if(writeitemdropsets(f, &header)!=0) |
| 14766 | ✗ | return 25; | |
| 14767 | |||
| 14768 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14769 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14770 | |||
| 14771 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("Writing Favorite Combos..."); |
| 14772 | |||
| 14773 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(writefavorites(f, &header)!=0) |
| 14774 | ✗ | return 26; | |
| 14775 | |||
| 14776 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_out("okay."); |
| 14777 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | box_eol(); |
| 14778 | |||
| 14779 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | pack_fclose(f); |
| 14780 | |||
| 14781 | |||
| 14782 |
3/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
9 | if(header.use_keyfile&&header.dirty_password) |
| 14783 | { | ||
| 14784 | ✗ | char const* kfname = filename; | |
| 14785 | ✗ | char keyfilename[2048]={0}; | |
| 14786 | ✗ | zprint2("Writing key files for '%s'\n", kfname, ".zpwd", ".zcheat"); | |
| 14787 | |||
| 14788 | ✗ | char temp_pw[QSTPWD_LEN] = {0}; | |
| 14789 | ✗ | uint ind = 0; | |
| 14790 | ✗ | for(char const* ext : {"key","zpwd","zcheat"}) | |
| 14791 | { | ||
| 14792 | ✗ | replace_extension(keyfilename, kfname, ext, 2047); | |
| 14793 | ✗ | PACKFILE *fp = pack_fopen_password(keyfilename, F_WRITE, ""); | |
| 14794 | ✗ | char msg[80] = {0}; | |
| 14795 | ✗ | sprintf(msg, "ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"); | |
| 14796 | ✗ | msg[78]=13; | |
| 14797 | ✗ | msg[79]=10; | |
| 14798 | ✗ | pfwrite(msg, 80, fp); | |
| 14799 | ✗ | p_iputw(header.zelda_version,fp); | |
| 14800 | ✗ | p_putc(header.build,fp); | |
| 14801 | ✗ | char const* pwd = header.password; | |
| 14802 | ✗ | if(ind == 2) //.zcheat, hashed pwd | |
| 14803 | { | ||
| 14804 | ✗ | char hashmap = 'Z'; | |
| 14805 | ✗ | hashmap += 'Q'; | |
| 14806 | ✗ | hashmap += 'U'; | |
| 14807 | ✗ | hashmap += 'E'; | |
| 14808 | ✗ | hashmap += 'S'; | |
| 14809 | ✗ | hashmap += 'T'; | |
| 14810 | ✗ | for ( int q = 0; q < QSTPWD_LEN; ++q ) | |
| 14811 | { | ||
| 14812 | ✗ | temp_pw[q] = header.password[q]; | |
| 14813 | ✗ | temp_pw[q] += hashmap; | |
| 14814 | ✗ | } | |
| 14815 | ✗ | pwd = temp_pw; | |
| 14816 | ✗ | } | |
| 14817 | ✗ | pfwrite(pwd, strlen(pwd), fp); | |
| 14818 | ✗ | pack_fclose(fp); | |
| 14819 | ✗ | ++ind; | |
| 14820 | } | ||
| 14821 | ✗ | } | |
| 14822 | |||
| 14823 | // Move file to destination at end, to avoid issues with file being unavailable to test mode. | ||
| 14824 | 9 | std::error_code ec; | |
| 14825 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | fs::rename(tmp_filename, filename, ec); |
| 14826 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (ec) |
| 14827 | { | ||
| 14828 | ✗ | al_trace("Error saving: %s\n", std::strerror(ec.value())); | |
| 14829 | ✗ | return ec.value(); | |
| 14830 | } | ||
| 14831 | |||
| 14832 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | strncpy(header.zelda_version_string, getVersionString(), sizeof(header.zelda_version_string)); |
| 14833 | |||
| 14834 | #ifdef __EMSCRIPTEN__ | ||
| 14835 | em_sync_fs(); | ||
| 14836 | #endif | ||
| 14837 | |||
| 14838 | 9 | return 0; | |
| 14839 | 9 | } | |
| 14840 | |||
| 14841 | // #ifdef _WIN32 | ||
| 14842 | // static std::time_t to_time_t(FILETIME const& ft) { | ||
| 14843 | // uint64_t t = (static_cast<uint64_t>(ft.dwHighDateTime) << 32) | ft.dwLowDateTime; | ||
| 14844 | // t -= 116444736000000000ull; | ||
| 14845 | // t /= 10000000u; | ||
| 14846 | // return static_cast<std::time_t>(t); | ||
| 14847 | // } | ||
| 14848 | // #else | ||
| 14849 | // #endif | ||
| 14850 | template<typename TP> | ||
| 14851 | 6 | static std::time_t to_time_t(TP tp) { | |
| 14852 | using namespace std::chrono; | ||
| 14853 | 6 | auto sctp = time_point_cast<system_clock::duration>(tp - TP::clock::now() + system_clock::now()); | |
| 14854 | 6 | return system_clock::to_time_t(sctp); | |
| 14855 | } | ||
| 14856 | |||
| 14857 | 6 | std::string get_time_last_modified_string(std::string path) | |
| 14858 | { | ||
| 14859 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | auto write_time = fs::last_write_time(path); |
| 14860 | // TODO: C++20 but not supported yet. | ||
| 14861 | // auto tt = std::chrono::clock_cast<std::chrono::system_clock>(write_time); | ||
| 14862 | 6 | std::time_t tt = to_time_t(write_time); | |
| 14863 | 6 | std::tm *gmt = std::gmtime(&tt); | |
| 14864 | 6 | std::stringstream buffer; | |
| 14865 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | buffer << std::put_time(gmt, "%Y-%m-%d"); |
| 14866 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | std::string formattedFileTime = buffer.str(); |
| 14867 | 6 | return formattedFileTime; | |
| 14868 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | } |
| 14869 | |||
| 14870 | 9 | int32_t save_unencoded_quest(const char *filename, bool compressed, const char *afname) | |
| 14871 | { | ||
| 14872 | // Always backup quest if it was last saved in a different version of the editor, | ||
| 14873 | // or if this a new file and is overwritting another qst file. | ||
| 14874 |
10/16✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 6 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
9 | if (exists(filename) && std::string(getVersionString()) != header.zelda_version_string) |
| 14875 | { | ||
| 14876 | 6 | std::string backup_name; | |
| 14877 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | std::string last_mod = get_time_last_modified_string(filename); |
| 14878 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if (strlen(header.zelda_version_string) > 0) |
| 14879 | { | ||
| 14880 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | backup_name = fmt::format("{}-v{}", last_mod, header.zelda_version_string); |
| 14881 | 6 | } | |
| 14882 | else | ||
| 14883 | { | ||
| 14884 | ✗ | backup_name = fmt::format("{}", last_mod); | |
| 14885 | } | ||
| 14886 |
7/14✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
|
6 | std::string backup_fname = fmt::format("{}-{}{}", fs::path(filename).stem().string(), backup_name, fs::path(filename).extension().string()); |
| 14887 |
3/6✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
6 | fs::path backup_path = fs::path("backups") / backup_fname; |
| 14888 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | if (!fs::exists(backup_path)) |
| 14889 | { | ||
| 14890 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | fs::create_directories(fs::path("backups")); |
| 14891 |
3/6✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
6 | if (fs::copy_file(filename, backup_path)) |
| 14892 | { | ||
| 14893 |
5/10✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6 times.
|
6 | InfoDialog("Quest Backup", fmt::format("A backup has been saved to {}", backup_path.string())).show(); |
| 14894 | 6 | } | |
| 14895 | else | ||
| 14896 | { | ||
| 14897 | ✗ | InfoDialog("Quest Backup", fmt::format("Failed to save backup at {}", backup_path.string())).show(); | |
| 14898 | } | ||
| 14899 | 6 | } | |
| 14900 | 6 | } | |
| 14901 | |||
| 14902 | 9 | auto ret = _save_unencoded_quest_int(filename,compressed,afname); | |
| 14903 | 9 | fake_pack_writing = false; | |
| 14904 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(ret) |
| 14905 | { | ||
| 14906 | ✗ | box_out("-- Error saving quest file! --"); | |
| 14907 | ✗ | box_end(true); | |
| 14908 | ✗ | } | |
| 14909 | 9 | else box_end(false); | |
| 14910 | 9 | return ret; | |
| 14911 | ✗ | } | |
| 14912 | |||
| 14913 | 9 | int32_t save_quest(const char *filename, bool timed_save) | |
| 14914 | { | ||
| 14915 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | int32_t retention=timed_save?AutoSaveRetention:AutoBackupRetention; |
| 14916 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | bool compress=!(timed_save&&UncompressedAutoSaves); |
| 14917 | char ext1[5]; | ||
| 14918 | 9 | ext1[0]=0; | |
| 14919 | |||
| 14920 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(timed_save) |
| 14921 | { | ||
| 14922 | ✗ | sprintf(ext1, "qt"); | |
| 14923 | ✗ | } | |
| 14924 | else | ||
| 14925 | { | ||
| 14926 | 9 | sprintf(ext1, "qb"); | |
| 14927 | } | ||
| 14928 | |||
| 14929 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(retention) |
| 14930 | { | ||
| 14931 | char backupname[2048]; | ||
| 14932 | char backupname2[2048]; | ||
| 14933 | char ext[12]; | ||
| 14934 | |||
| 14935 | ✗ | for(int32_t i=retention-1; i>0; --i) | |
| 14936 | { | ||
| 14937 | ✗ | sprintf(ext, "%s%d", ext1, i-1); | |
| 14938 | ✗ | replace_extension(backupname, filepath, ext, 2047); | |
| 14939 | |||
| 14940 | ✗ | if(exists(backupname)) | |
| 14941 | { | ||
| 14942 | ✗ | sprintf(ext, "%s%d", ext1, i); | |
| 14943 | ✗ | replace_extension(backupname2, filepath, ext, 2047); | |
| 14944 | |||
| 14945 | ✗ | if(exists(backupname2)) | |
| 14946 | { | ||
| 14947 | ✗ | remove(backupname2); | |
| 14948 | ✗ | } | |
| 14949 | |||
| 14950 | ✗ | rename(backupname, backupname2); | |
| 14951 | ✗ | } | |
| 14952 | ✗ | } | |
| 14953 | |||
| 14954 | //don't do this if we're not saving to the same name -DD | ||
| 14955 | ✗ | if(!timed_save && !strcmp(filepath, filename)) | |
| 14956 | { | ||
| 14957 | ✗ | sprintf(ext, "%s%d", ext1, 0); | |
| 14958 | ✗ | replace_extension(backupname, filepath, ext, 2047); | |
| 14959 | ✗ | rename(filepath, backupname); | |
| 14960 | ✗ | } | |
| 14961 | ✗ | } | |
| 14962 | |||
| 14963 | int32_t ret; | ||
| 14964 | 9 | ret = save_unencoded_quest(filename, compress, filename); | |
| 14965 | |||
| 14966 | 9 | return ret; | |
| 14967 | } | ||
| 14968 | |||
| 14969 | 8 | void center_zq_class_dialogs() | |
| 14970 | { | ||
| 14971 | 8 | jwin_center_dialog(pwd_dlg); | |
| 14972 | 8 | } | |
| 14973 | |||
| 14974 | ✗ | void zmap::prv_secrets(bool high16only) | |
| 14975 | { | ||
| 14976 | ✗ | mapscr *s = &prvscr; | |
| 14977 | ✗ | mapscr *t = prvlayers; | |
| 14978 | ✗ | int32_t ft=0; | |
| 14979 | |||
| 14980 | ✗ | for(int32_t i=0; i<176; i++) | |
| 14981 | { | ||
| 14982 | ✗ | if(!high16only) | |
| 14983 | { | ||
| 14984 | ✗ | for(int32_t j=-1; j<6; j++) | |
| 14985 | { | ||
| 14986 | ✗ | int32_t newflag = -1; | |
| 14987 | |||
| 14988 | ✗ | for(int32_t iter=0; iter<2; ++iter) | |
| 14989 | { | ||
| 14990 | ✗ | if(!t[j].valid) | |
| 14991 | ✗ | continue; | |
| 14992 | |||
| 14993 | ✗ | int32_t checkflag=combobuf[t[j].data[i]].flag; | |
| 14994 | |||
| 14995 | ✗ | if(iter==1) | |
| 14996 | { | ||
| 14997 | ✗ | checkflag=t[j].sflag[i]; | |
| 14998 | ✗ | } | |
| 14999 | |||
| 15000 | ✗ | ft = combo_trigger_flag_to_secret_combo_index(checkflag); | |
| 15001 | ✗ | if (ft != -1) | |
| 15002 | { | ||
| 15003 | ✗ | if(j==-1) | |
| 15004 | { | ||
| 15005 | ✗ | s->data[i] = s->secretcombo[ft]; | |
| 15006 | ✗ | s->cset[i] = s->secretcset[ft]; | |
| 15007 | ✗ | newflag = s->secretflag[ft]; | |
| 15008 | ✗ | } | |
| 15009 | else | ||
| 15010 | { | ||
| 15011 | ✗ | t[j].data[i] = t[j].secretcombo[ft]; | |
| 15012 | ✗ | t[j].cset[i] = t[j].secretcset[ft]; | |
| 15013 | ✗ | newflag = t[j].secretflag[ft]; | |
| 15014 | } | ||
| 15015 | ✗ | } | |
| 15016 | ✗ | } | |
| 15017 | |||
| 15018 | ✗ | if(newflag >-1) | |
| 15019 | { | ||
| 15020 | ✗ | ((j==-1) ? s->sflag[i] : t[j].sflag[i]) = newflag; | |
| 15021 | ✗ | } | |
| 15022 | ✗ | } | |
| 15023 | ✗ | } | |
| 15024 | |||
| 15025 | //if(true) | ||
| 15026 | //{ | ||
| 15027 | ✗ | int32_t newflag = -1; | |
| 15028 | |||
| 15029 | ✗ | for(int32_t iter=0; iter<2; ++iter) | |
| 15030 | { | ||
| 15031 | ✗ | int32_t checkflag=combobuf[s->data[i]].flag; | |
| 15032 | |||
| 15033 | ✗ | if(iter==1) | |
| 15034 | { | ||
| 15035 | ✗ | checkflag=s->sflag[i]; | |
| 15036 | ✗ | } | |
| 15037 | |||
| 15038 | ✗ | if((checkflag > 15)&&(checkflag < 32)) | |
| 15039 | { | ||
| 15040 | ✗ | s->data[i] = s->secretcombo[(checkflag)-16+4]; | |
| 15041 | ✗ | s->cset[i] = s->secretcset[(checkflag)-16+4]; | |
| 15042 | ✗ | newflag = s->secretflag[(checkflag)-16+4]; | |
| 15043 | // putit = true; | ||
| 15044 | ✗ | } | |
| 15045 | ✗ | } | |
| 15046 | |||
| 15047 | ✗ | if(newflag >-1) s->sflag[i] = newflag; | |
| 15048 | |||
| 15049 | ✗ | for(int32_t j=0; j<6; j++) | |
| 15050 | { | ||
| 15051 | ✗ | if(!t[j].valid) continue; | |
| 15052 | |||
| 15053 | ✗ | int32_t newflag2 = -1; | |
| 15054 | |||
| 15055 | ✗ | for(int32_t iter=0; iter<2; ++iter) | |
| 15056 | { | ||
| 15057 | ✗ | int32_t checkflag=combobuf[t[j].data[i]].flag; | |
| 15058 | |||
| 15059 | ✗ | if(iter==1) | |
| 15060 | { | ||
| 15061 | ✗ | checkflag=t[j].sflag[i]; | |
| 15062 | ✗ | } | |
| 15063 | |||
| 15064 | ✗ | if((checkflag > 15)&&(checkflag < 32)) | |
| 15065 | { | ||
| 15066 | ✗ | t[j].data[i] = t[j].secretcombo[(checkflag)-16+4]; | |
| 15067 | ✗ | t[j].cset[i] = t[j].secretcset[(checkflag)-16+4]; | |
| 15068 | ✗ | newflag2 = t[j].secretflag[(checkflag)-16+4]; | |
| 15069 | ✗ | } | |
| 15070 | ✗ | } | |
| 15071 | |||
| 15072 | ✗ | if(newflag2 >-1) t[j].sflag[i] = newflag2; | |
| 15073 | ✗ | } | |
| 15074 | ✗ | } | |
| 15075 | |||
| 15076 | //FFCs | ||
| 15077 | ✗ | word num_ffcs = s->numFFC(); | |
| 15078 | ✗ | for(word i=0; i<num_ffcs; ++i) | |
| 15079 | { | ||
| 15080 | ✗ | if(!high16only) | |
| 15081 | { | ||
| 15082 | ✗ | for(int32_t iter=0; iter<1; ++iter) | |
| 15083 | { | ||
| 15084 | ✗ | int32_t checkflag=combobuf[s->ffcs[i].data].flag; | |
| 15085 | |||
| 15086 | ✗ | if(iter==1) | |
| 15087 | { | ||
| 15088 | ✗ | checkflag=s->sflag[i]; | |
| 15089 | ✗ | } | |
| 15090 | |||
| 15091 | ✗ | ft = combo_trigger_flag_to_secret_combo_index(checkflag); | |
| 15092 | ✗ | if (ft != -1) | |
| 15093 | { | ||
| 15094 | ✗ | s->ffcs[i].data = s->secretcombo[ft]; | |
| 15095 | ✗ | s->ffcs[i].cset = s->secretcset[ft]; | |
| 15096 | ✗ | } | |
| 15097 | ✗ | } | |
| 15098 | ✗ | } | |
| 15099 | |||
| 15100 | ✗ | if(!(s->flags2&fCLEARSECRET) || high16only || s->flags4&fENEMYSCRTPERM) | |
| 15101 | { | ||
| 15102 | ✗ | for(int32_t iter=0; iter<1; ++iter) | |
| 15103 | { | ||
| 15104 | ✗ | int32_t checkflag=combobuf[s->ffcs[i].data].flag; | |
| 15105 | |||
| 15106 | ✗ | if(iter==1) | |
| 15107 | { | ||
| 15108 | // FFCs can't have flags! Yet... | ||
| 15109 | ✗ | } | |
| 15110 | |||
| 15111 | ✗ | if((checkflag > 15)&&(checkflag < 32)) | |
| 15112 | { | ||
| 15113 | ✗ | s->ffcs[i].data = s->secretcombo[checkflag - 16 + 4]; | |
| 15114 | ✗ | s->ffcs[i].cset = s->secretcset[checkflag-16+4]; | |
| 15115 | ✗ | } | |
| 15116 | ✗ | } | |
| 15117 | ✗ | } | |
| 15118 | ✗ | } | |
| 15119 | ✗ | } | |
| 15120 |